• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wrapper class constructors

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All!

Compiler complains for the following code -->

public class XXX {
public static void main(String args[]) {
byte a = 10;
Byte x = new Byte(a);
Byte y = new Byte(11);//compiler complains
System.out.println(x.compareTo(y));
}
}


Why the compiler does not complain for the following code -->

public class ZZZ {
public static void main(String args[]) {
Float f = new Float(32D);//compiler does not complain
System.out.println(f);
}
}

pls clarify..Thanks
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you by any chance looked at the API for these classes?
 
Ranch Hand
Posts: 111
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just go through the java doc.
In your first code 11 is "int" that is default type for integer type and there is constructor defined which take "int" and "int" is not automatically converted into byte .
if you change your code to
Byte y = new Byte((byte)11);// compiles fine

second code is perfectly fine
there is a constructor defined
Float(double value) in API just go through it.

Regards,

Abdul Mohsin
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check with the javaDoc,
there is no costructor for new Byte(int value)
but, there is a constructor for new Float(double value).
 
Neha Monga
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay...i found my answer in API...

thanks
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"krishna" while we appreciate your responses to the questions on this forum, you are getting near the post count limit where we close your access to JavaRanch for disregarding our JavaRanch Naming Policy. So please change your display name immediately (in brief: <first name><space><family name> ;) .

Thanks
-Barry

(close)
[ May 23, 2007: Message edited by: Barry Gaunt ]
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have changed my dispaly name.
Is there any post count limit here? I really don't know that
if yes, can you tell me or give the link where can i get that information.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by krishna:
I have changed my dispaly name.
Is there any post count limit here? I really don't know that
if yes, can you tell me or give the link where can i get that information.



You do not need to know about the post count exact limit when we lock your account when it has an invalid display name. You have just to worry about getting your display name changed.

Your display name seems to still be "krishna", what did you change it too?
[ May 23, 2007: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barry

Is there any limits on the number of posts ? If so on what frequency its taken into account?

If it really matters, can you please redirect us to the page where we will be educated on it!

Thank you.
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

[RM]:Is there any limits on the number of posts ? If so on what frequency its taken into account?

I think, no I'm sure Barry was referring to the fact that incase you do have a display name that does not meets the Javaranch standards then your account could be deleted.

[EDIT] Had forgot to add the does not words in my orignal post.
[ May 24, 2007: Message edited by: Anupam Sinha ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anupam Sinha:
Hi

[RM]:Is there any limits on the number of posts ? If so on what frequency its taken into account?

I think, no I'm sure Barry was referring to the fact that incase you do have a display name that does not meets the Javaranch standards then your account could be deleted.



Exactly.
[ May 29, 2007: Message edited by: Barry Gaunt ]
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic