|
-
Nov 12th, 2001, 10:56 AM
#1
Thread Starter
Hyperactive Member
.intern() ?
What does .intern() do when handling strings? For example, if I have a string variable called myString and I do the following:
someOtherVariable = myString.intern();
What does it store in the other one?
-JR-
"Blessed are we who can laugh at ourselves for we shall never cease to be amused"
- Unknown
-
Nov 12th, 2001, 11:05 AM
#2
Dazed Member
The signature of the method is public String intern(); so i assume that it returns a String but i noticed also that it is declared native.
-
Nov 12th, 2001, 11:08 AM
#3
Thread Starter
Hyperactive Member
Ahem, I'm pretty new to java... What would that be in english? 
-JR-
"Blessed are we who can laugh at ourselves for we shall never cease to be amused"
- Unknown
-
Nov 12th, 2001, 11:10 AM
#4
Thread Starter
Hyperactive Member
Oh, I'm sorry, if I presented the problem the wrong way:
What does it do to the string? (i.e. Trim() takes off preceeding and following spaces)
-JR-
"Blessed are we who can laugh at ourselves for we shall never cease to be amused"
- Unknown
-
Nov 12th, 2001, 11:13 AM
#5
Dazed Member
You can do somthing like this to run a native method, which is a method from another language. Since Java can only run C++ i guess that it is a C++ method, im not too sure though.
Code:
public class Native{
/* the static initializer ensures that the native library
will be loaded before the methood is called
*/
static{
System.loadLibrary(NativeLibrarylib);
}
public void nativeMethod(); //native method protype
}
-
Nov 12th, 2001, 11:15 AM
#6
Thread Starter
Hyperactive Member
Originally posted by Jareware
Oh, I'm sorry, if I presented the problem the wrong way:
What does it do to the string? (i.e. Trim() takes off preceeding and following spaces)
-JR-
"Blessed are we who can laugh at ourselves for we shall never cease to be amused"
- Unknown
-
Nov 12th, 2001, 11:17 AM
#7
Dazed Member
That i have no clue. My documentation doesn't say.
-
Nov 12th, 2001, 11:19 AM
#8
Thread Starter
Hyperactive Member
I see... Have you tried using it?
-JR-
"Blessed are we who can laugh at ourselves for we shall never cease to be amused"
- Unknown
-
Nov 12th, 2001, 11:32 AM
#9
Dazed Member
Nope. Never had a need too.
-
Nov 12th, 2001, 01:11 PM
#10
Thread Starter
Hyperactive Member
Well, me neither, I just need to know what it does 
-JR-
"Blessed are we who can laugh at ourselves for we shall never cease to be amused"
- Unknown
-
Nov 12th, 2001, 04:14 PM
#11
public String intern()Returns a canonical representation for the string object.
A pool of strings, initially empty, is maintained privately by the class String.
When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.
It follows that for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.
All literal strings and string-valued constant expressions are interned. String literals are defined in §3.10.5 of the Java Language Specification
Returns:
a string that has the same contents as this string, but is guaranteed to be from a pool of unique strings.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Nov 13th, 2001, 08:01 AM
#12
Thread Starter
Hyperactive Member
K, thanks, I'll try and figure out what you meant... 
-JR-
"Blessed are we who can laugh at ourselves for we shall never cease to be amused"
- Unknown
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|