class WrapperTest
	public static void main(String[] args){
		Byte b = new Byte(3);
		Short s = new Short(34);

when I try to compile this is the problem I got

G:\WORK PLACE\work>javac cannot find symbol
symbol  : constructor Byte(int)
location: class java.lang.Byte
                Byte b = new Byte(4);
                         ^ cannot find symbol
symbol  : constructor Short(int)
location: class java.lang.Short
                Short s = new Short(34);
2 errors

Please tell me What is the problem of that constructor.

Recommended Answers

All 2 Replies

Probably because there isn't such constructor.
API for Byte object
API for Short object
The values in the parenthesis are not treated as byte and short but as int. I haven't try this and I don't know if it will work so don't blame me, but try:
Byte b = new Byte( (byte)3 );
Short s = new Short( (short)34 );

Actually it works

if we do like this.

Byte b = 3;
Short s = 34;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.