Originally posted by gabrielf:
String s = new String(10);
Is a perfectly valid java statement Thanks,
/Gabbe
I don't know
WHAT version of the JDK you are using, but in 1.3 there is no constructor in java.lang.String matches <init>(int).
Therefore you are wrong!
I am not sure what you are trying to do, but I think
String s = new String("10");
might be what you are looking for.
Read the Javadoc for java.lang.String, and you will see:
Constructor Summary
String()
Initializes a newly created String object so that it represents an empty character sequence.
String(byte[] bytes)
Construct a new String by converting the specified array of bytes using the platform's default character encoding.
String(byte[] ascii, int hibyte)
Deprecated. This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the String constructors that take a character-encoding name or that use the platform's default encoding.
String(byte[] bytes, int offset, int length)
Construct a new String by converting the specified subarray of bytes using the platform's default character encoding.
String(byte[] ascii, int hibyte, int offset, int count)
Deprecated. This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the String constructors that take a character-encoding name or that use the platform's default encoding.
String(byte[] bytes, int offset, int length, String enc)
Construct a new String by converting the specified subarray of bytes using the specified character encoding.
String(byte[] bytes, String enc)
Construct a new String by converting the specified array of bytes using the specified character encoding.
String(char[] value)
Allocates a new String so that it represents the sequence of characters currently contained in the character array argument.
String(char[] value, int offset, int count)
Allocates a new String that contains characters from a subarray of the character array argument.
String(String value)
Initializes a newly created String object so that it represents the same sequence of characters as the argument; in other words, the newly created string is a copy of the argument string.
String(StringBuffer buffer)
Allocates a new string that contains the sequence of characters currently contained in the string buffer argument.