Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Beginning Java
"this" ???
pras
Ranch Hand
Posts: 188
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Test6{
public Test6(){
this(4);/***********??? ****/
}
public Test6(byte var){
System.out.println(var);
}
public static void main(
String
[] args){
Test6 t6 = new Test6();
}
}
/**** why is 4 not passed to public Test6 constructer?
John Dell'Oso
Ranch Hand
Posts: 130
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Have a look at this:
public class Test6 { public Test6() { this((byte)4); } public Test6(byte var) { System.out.println(var); } public static void main(String[] args) { Test6 t6 = new Test6(); } }
The second constructor is expecting a byte. You have to use a cast as the literal 4 is assumed to be an integral type.
Regards,
JD
[ August 01, 2007: Message edited by: John Dell'Oso ]
pras
Ranch Hand
Posts: 188
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thanks john
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
constructor doubt
constructor doubt
constructor doubt
HashSet Duplicate element ?
Constructors question
More...