TypeCasting String To List

Is ther any possible way to typecast String to List...

thanks

[74 byte] By [Brucepaynea] at [2007-11-27 10:57:38]
# 1

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?

georgemca at 2007-7-29 12:10:29 > top of Java-index,Java Essentials,Java Programming...
# 2

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.

malcolmmca at 2007-7-29 12:10:29 > top of Java-index,Java Essentials,Java Programming...
# 3

> 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!

jGardnera at 2007-7-29 12:10:29 > top of Java-index,Java Essentials,Java Programming...
# 4

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

georgemca at 2007-7-29 12:10:29 > top of Java-index,Java Essentials,Java Programming...
# 5

> 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...

Hippolytea at 2007-7-29 12:10:29 > top of Java-index,Java Essentials,Java Programming...