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
Win a copy of
Eclipse Collections Categorically: Level up your programming game
this week in the
Open Source Projects
forum!
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
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Beginning Java
"this" ???
pras
Ranch Hand
Posts: 188
posted 17 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 17 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 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thanks john
grapes are vegan food pellets. Eat this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
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...