Posted by Anonymous Wed 28th Feb 2007 14:38 - Syntax is Java - 19 views
Modification of posting from Anonymous Wed 28th Feb 2007 14:18
Download | New Post | Modify | Diff | Hide line numbers
Modification of posting from Anonymous Wed 28th Feb 2007 14:18
Download | New Post | Modify | Diff | Hide line numbers
-
import java.util.Vector;
-
-
public class vectors {
-
-
/**
-
* @param args
-
*/
-
public static void main([] args) {
-
v = new ();
-
v.add("TestA");
-
v.add("TestB");
-
v.add("TestC");
-
//does not compile without conversion
-
//String back = v.get(1);
-
back = () v.get(1);
-
.out.println(back);
-
-
//does not compile
-
//String[] list1 = v.toArray();
-
//compiles, but doesnt run
-
//String[] list2 = (String []) v.toArray();
-
//this appears to work though
-
[] list3 = new [v.size()];
-
v.toArray(list3);
-
//and this is it on one line
-
[] list4 = ([]) v.toArray(new [v.size()]);
-
-
//looping way to do it
-
[] list5 = new [v.size()];
-
for (int i = 0; i < v.size(); i++){
-
list5[i] = () v.get(i);
-
}
-
-
//debug printouts
-
//for (int i = 0; i < list1.length; i++){System.out.println(list1[i]);}
-
//for (int i = 0; i < list2.length; i++){System.out.println(list2[i]);}
-
for (int i = 0; i < list3.length; i++){.out.println(list3[i]);}
-
for (int i = 0; i < list4.length; i++){.out.println(list4[i]);}
-
for (int i = 0; i < list5.length; i++){.out.println(list5[i]);}
-
}
-
}
PermaLink to this entry https://pastebin.co.uk/11162
Posted by Anonymous Wed 28th Feb 2007 14:38 - Syntax is Java - 19 views
Modification of posting from Anonymous Wed 28th Feb 2007 14:18
Download | New Post | Modify | Diff | Hide line numbers
Modification of posting from Anonymous Wed 28th Feb 2007 14:18
Download | New Post | Modify | Diff | Hide line numbers
Comments: 0