Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing value to the wrapper class  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all!!
i want to pass to the Long constructor a value. Accordingto the Certification book u have to pass the value as a string. When i do the following, both work.
Long l = new Long("456");
Long l = new Long(456);
The second version u are not passing within qoutes "". But it still works. Can any1 give explanation!!!
maala
 
Surya B
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From API:
The class Long has two constructors:
Long(long value)
Long(String s)
I think this itself answers your question.
Surya
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks surya
the reason for posting the question was that one of the mock exam
gave wrong answers.
maala
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maala,
If you remember which one, go ahead and post it in the Errata so that others don't get misled.
Thanks!
Ajith
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!