Name: Anonymous 2008-03-15 20:39
Noob programmer here, I can't figure out why I keep getting the error "Cannot find symbol class ArrayList".
import java.awt.*;
import javax.swing.*;
import java.util.Scanner;
public class MyArray{
public static void main() {
int i=0, thesame, size;
ArrayList<String> list = new ArrayList<String>();
Scanner input = new Scanner(System.in);
bString = "done";
for(i=0;i!=2.5;i++){
System.out.print("Enter a name");
nextWord = input.nextString;
list.add(i, nextWord);
boolean theSame = bString.equals("Done");
if(theSame = 0)
i = 1.5;
}
int size = list.size();
for(i=0;i<=0;i++){
String temp = copy.get(i);
System.out.print(temp);
}
}
public ArrayList sort(ArrayList list){
int top, i, maxIdx, copy1;
ArrayList<Sring> copy = new ArrayList<String>(list.size());
for (int i = 0;i < list.size;i++)
copy.add((string)list.get(i));
for (int top=copy.size-1;top > 0;top--) {
ArrayList maximum = ((string)copy.get(0));
int maxIdx = 0;
for (int search=1;search <= top;search++){
String name = ((string)copy.get(search)) ;
String topName = ((string)copy.get(top)) ;
if (name.compareTo(top) = 1) {
Sting maximum = ((string)copy.get(search));
maxIdx = search;
}
}
if (maxIdx != top) {
ArrayList swap = ((string)copy.get(top));
copy1= ((string)copy.get(maxIdx));
copy.set(top,copy1);
copy.set(maxIdx,swap);
}
}
return copy;
}
}
import java.awt.*;
import javax.swing.*;
import java.util.Scanner;
public class MyArray{
public static void main() {
int i=0, thesame, size;
ArrayList<String> list = new ArrayList<String>();
Scanner input = new Scanner(System.in);
bString = "done";
for(i=0;i!=2.5;i++){
System.out.print("Enter a name");
nextWord = input.nextString;
list.add(i, nextWord);
boolean theSame = bString.equals("Done");
if(theSame = 0)
i = 1.5;
}
int size = list.size();
for(i=0;i<=0;i++){
String temp = copy.get(i);
System.out.print(temp);
}
}
public ArrayList sort(ArrayList list){
int top, i, maxIdx, copy1;
ArrayList<Sring> copy = new ArrayList<String>(list.size());
for (int i = 0;i < list.size;i++)
copy.add((string)list.get(i));
for (int top=copy.size-1;top > 0;top--) {
ArrayList maximum = ((string)copy.get(0));
int maxIdx = 0;
for (int search=1;search <= top;search++){
String name = ((string)copy.get(search)) ;
String topName = ((string)copy.get(top)) ;
if (name.compareTo(top) = 1) {
Sting maximum = ((string)copy.get(search));
maxIdx = search;
}
}
if (maxIdx != top) {
ArrayList swap = ((string)copy.get(top));
copy1= ((string)copy.get(maxIdx));
copy.set(top,copy1);
copy.set(maxIdx,swap);
}
}
return copy;
}
}