Results 1 to 2 of 2
  1. #1
    ronnie is offline Member
    Join Date
    Feb 2012
    Posts
    5
    Rep Power
    0

    Default 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

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

Similar Threads

  1. vm arguments
    By mharsijamel in forum NetBeans
    Replies: 4
    Last Post: 01-02-2012, 01:40 PM
  2. Problem passing arrayed arguments to a method
    By vcl in forum New To Java
    Replies: 1
    Last Post: 06-27-2011, 08:04 PM
  3. Arguments
    By maya700 in forum New To Java
    Replies: 12
    Last Post: 02-01-2011, 06:57 PM
  4. help with arguments
    By smilinglady in forum New To Java
    Replies: 33
    Last Post: 01-27-2011, 04:10 AM
  5. Replies: 8
    Last Post: 09-23-2010, 01:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •