Advertisement
apl-mhd

OOP constructorOverloading

May 30th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Main {
  4.  
  5.     String motto;
  6.  
  7.     int id;
  8.  
  9.      Main(String  m){
  10.  
  11.          motto = m;
  12.          System.out.println(motto);
  13.  
  14.     }
  15.  
  16.  
  17.     Main(int i,String  m){
  18.  
  19.         id = i;
  20.         motto = m;
  21.         System.out.println("Id: "+id);
  22.         System.out.println("Motto: "+motto);
  23.  
  24.     }
  25.  
  26.  
  27.     public static void main(String[] args) {
  28.  
  29.  
  30.         Main  one = new Main("tui akta harami");
  31.         Main  two = new Main(1,"tui akta harami");
  32.  
  33.  
  34.  
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement