Results 1 to 4 of 4
Thread: string doubt
- 08-01-2007, 03:31 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 36
- Rep Power
- 0
- 08-02-2007, 02:55 AM #2
s is a String.
str is a copy of the String argument "abc". Since strings in java are immutable, the second statement is not necessary unless you need a copy of the argument string. See String api.
- 08-02-2007, 03:47 AM #3
Senior Member
- Join Date
- Jul 2007
- Posts
- 130
- Rep Power
- 0
From what i learn so far, in Java, String is an object, not a primitive type
The default way to create an object is by using the new keyword, like in the 2nd statement u wrote
But as to the impractical way of using a new keyword each time u create a String -which the designer assume are going to be often that is, and it certainly does- the language designer deiced to put a shortcut to instantiate a String without using the new keyword, and also to make it look similar like how u would initialize a String in other programming language
- 08-02-2007, 01:43 PM #4
Member
- Join Date
- Jul 2007
- Posts
- 36
- Rep Power
- 0
Similar Threads
-
doubt
By shaju_inspira in forum Sun Java Wireless ToolkitReplies: 0Last Post: 01-18-2008, 08:38 AM -
doubt in jms
By veena in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 01-05-2008, 01:42 PM -
doubt about PRINT API
By valery in forum New To JavaReplies: 1Last Post: 08-06-2007, 09:51 PM -
doubt about synchronized
By simon in forum Advanced JavaReplies: 2Last Post: 08-05-2007, 03:49 AM -
Doubt with classpath
By fred in forum New To JavaReplies: 1Last Post: 07-24-2007, 01:58 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks