Results 1 to 2 of 2
Thread: arguments problem
- 03-25-2012, 11:01 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
arguments problem
So
here's my main class
class Objectsmultiplecnstrctrs {
public static void main(String args[]){
ObjectsForMultipleConstructors engg2=new ObjectsForMultipleConstructors(1);
ObjectsForMultipleConstructors engg3=new ObjectsForMultipleConstructors(1,2);
ObjectsForMultipleConstructors engg=new ObjectsForMultipleConstructors(1,2,3);
}
}
and below is secondary class
public class ObjectsForMultipleConstructors {
private int hour;
private int minute;
private int second;
public ObjectsForMultipleConstructors(int h){
this.hour=h;
System.out.printf("give one ",+hour);
}
public ObjectsForMultipleConstructors(int h,int m){
System.out.printf("goddamn ",+m);
}
public ObjectsForMultipleConstructors(int h,int m,int s){
System.out.println("guess");
}
}
OUTPUT is give one goddamn guess
Now the problem is i have declared int hour =h and value of h I assigned in the arguments in the main class,so im expecting the value of h which i defined to be displayed next to the text (System.out.printf("goddamn ",+m);) ,,but its not doing what i want it to do ,where im missing
- 03-25-2012, 12:12 PM #2
Re: arguments problem
the goddamn
printf is wrong: try System.out.printf("give one %d\n",+hour);
for detailed informations read Using Java's printf( ) Method : printf Method*«*Development*«*Java Tutorial carefully
Similar Threads
-
vm arguments
By mharsijamel in forum NetBeansReplies: 4Last Post: 01-02-2012, 12:40 PM -
Problem passing arrayed arguments to a method
By vcl in forum New To JavaReplies: 1Last Post: 06-27-2011, 07:04 PM -
Arguments
By maya700 in forum New To JavaReplies: 12Last Post: 02-01-2011, 05:57 PM -
help with arguments
By smilinglady in forum New To JavaReplies: 33Last Post: 01-27-2011, 03:10 AM -
Sorting objects with 2 strings arguments and 2 int arguments
By tirwit in forum New To JavaReplies: 8Last Post: 09-23-2010, 12:07 AM
Bookmarks