Results 1 to 3 of 3

Thread: Doubt about 09

  1. #1
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

    Default Doubt about 09

    Hey guys,

    I was writing a simple java code for passing array of objects as argument and i stumbled on this one when i ran the code. Now below is the code which i ran.

    // java program to pass array of objects as an argument

    class Emppe

    {

    String name;

    int no;


    public void setname(String n)

    {

    name = n;

    }

    public String getname()

    {

    return name;

    }

    public void setno(int x)

    {

    no= x;

    }


    public int getno()

    {

    return no;

    }

    public void get(Emppe[] e)

    {

    e = new Emppe[2];

    e[0] = new Emppe();

    e[0].setname("anil");

    e[0].setno(9); ------> e[0].setno(09)

    e[1]= new Emppe();

    e[1].setname("sridhar");

    e[1].setno(23);

    int i;

    for(i=0 ; i<2; i++)

    {

    System.out.println(e[i].getname());

    System.out.println(e[i].getno());

    }

    }

    }

    public class Emm

    {

    public static void main(String[] args)

    {

    Emppe r = new Emppe();

    Emppe[] t = new Emppe[2];

    r.get(t);

    }

    }

    Now when i ran the above code by replacing e[0].setno(9); with e[0].setno(09), i got this error >>> integer number too large:09. Does that doesn't fit into integer range???

    Please help.

    Thank you.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,019
    Blog Entries
    7
    Rep Power
    20

    Default

    The '0' character introduces an octal integer (base 8); of course 9 isn't an octal digit and causes your compiler to whine about it.

    kind regards,

    Jos

  3. #3
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

Similar Threads

  1. a doubt
    By Thia in forum New To Java
    Replies: 13
    Last Post: 11-24-2009, 02:26 AM
  2. Doubt
    By karthikeyan_raju in forum Advanced Java
    Replies: 11
    Last Post: 11-05-2009, 04:48 PM
  3. have doubt
    By ras_pari in forum Advanced Java
    Replies: 3
    Last Post: 10-01-2009, 09:51 AM
  4. doubt
    By shaju_inspira in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 01-18-2008, 08:38 AM
  5. doubt in jms
    By veena in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 01-05-2008, 01:42 PM

Posting Permissions

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