File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integral types

 
rimzim sinha
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am not able to understand why Byte b1= new Byte(1); line generates an error..
Pls explain what am I missing..

Also , I wud like to know how to identify double & float value;
is it that only if explicitly specified 10.0f it is a float,else 10.0 is a double

May be what i m asking is too simple..pls excuse

public class Test12{
public static void main(String a[]){
byte b = 100;
Byte b1= new Byte(1);
Byte b2 = new Byte(b);
System.out.println(b1 == b2);
System.out.println(b1.equals(b2));
}
}
 
Olivier Lambert
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, a floating point number is a double. If you want a float, you have to put a "f" next to your number.

example:
10.2, 12.36 are doubles,
25.689f is a float.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not able to understand why Byte b1= new Byte(1); line generates an error


The Byte constructor takes a byte or a String. The literal 1 is an int. So you must cast it: Byte b1= new Byte((byte)1);

See Corey's next article (really)
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also specify a double explicitly, for example: 42.0d
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic