Why in 1st code data sets to the string value, but in 2nd method I got ex about that it can't convert?Code: Select all
String[] data = event.split(" "); String[] val = data[1];
Question with string :)
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- KGB1st
- Posts: 230
- Joined: Sat Jul 26, 2014 5:58 pm
Question with string :)
- LasTravel
- Posts: 888
- Joined: Tue Jan 05, 2010 12:08 am
- Location: Spain
Re: Question with string :)
Because data[1] is a String, not a String[], so you should use:
Code: Select all
String val = data[1];
- KGB1st
- Posts: 230
- Joined: Sat Jul 26, 2014 5:58 pm
Re: Question with string :)
aaa.. this's such as dynmic sting (array)?LasTravel wrote:Because data[1] is a String, not a String[], so you should use:
Code: Select all
String val = data[1];
-
- Posts: 121
- Joined: Thu Oct 30, 2014 9:54 pm
Re: Question with string :)
Java is strictly typed. String#split(String) returns String[], which is a simple array.
A String in Java is not an array (although in typical JDK implementations there is a cached char[] underneath).
Consider
A String in Java is not an array (although in typical JDK implementations there is a cached char[] underneath).
Consider
Code: Select all
char[] val = data[1].toCharArray()