Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
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
Ron McLeod
Paul Clapham
Devaka Cooray
Tim Cooke
Sheriffs:
Rob Spoor
Liutauras Vilda
paul wheaton
Saloon Keepers:
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Piet Souris
Bartenders:
Stephan van Hulst
Forum:
Programmer Certification (OCPJP)
String and StringBuffer
Ravi Ahuja
Ranch Hand
Posts: 45
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hello freinds i wanted to know the reason behind the output of this particular program: class try1 { static void meth(String s) { System.out.print("String"); System.out.println(s); } static void meth(StringBuffer sb) { System.out.print("StringBuffer"); System.out.println(sb); } public static void main(String ar[]) { meth("invoked"); } }
[op]
This code gives the output as
Stringinvoked
Can Anyone explain Why ?
Thanks in advance
[/op]
Impossible is Nothing<br />SCJP 1.4: 96%
Keith Lynn
Ranch Hand
Posts: 2412
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
String
literals are always instances of String.
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
I don't understand this thread code behavior.
StringBuffer
String Buffer
StringBuffer and String returned from a method doubt
More...