TypeCasting String To List
Is ther any possible way to typecast String to List...
thanks
Is ther any possible way to typecast String to List...
thanks
Is there any way to spread the Cuban Missile Crisis on your toast? No. It's a mismatching of concepts
Much like Strings and Lists. But I bet your actual problem is something different. Why did you want to do this?
No, because typecasting is about telling the compiler that an object is already a certain type. Obviously, if you can specify the format, you can parse a String into a list (and a list of what?). It's not typecasting though.
> Is there any way to spread the Cuban Missile Crisis
> on your toast? No. It's a mismatching of concepts
>
> Much like Strings and Lists. But I bet your actual
> problem is something different. Why did you want to
> do this?
String s = "Test String";
char[] sca = s.toCharArray();
ArrayList<Character> l = new ArrayList();
for(char c : sca) {
l.add(c);
}
l is your Listy String.
Yay!
List list = Arrays.asList("some string here".toCharArray());
edit: doesn't work as expected :-(
Arrays sees the result of toCharArray as a 2-dimensional array, hence the List has 1 element - the char array
> Is there any way to spread the Cuban Missile Crisis on your toast? No. It's a mismatching of concepts
Close, though. I've seen a brand of dark-roasted coffee beans from Cuba that's called "Cuban Missile", so you could have a breakfast of toast and Cuban Missile...