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)) ;
ArrayList<String> copy = new ArrayList<String>(list.size());
tempSize = list.size;
for (i = 0;i < tempSize;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)) ;
ok so thanks for the help guys, but i have one final predicament, so i finally got it all debugged with no syntax errors, but now when i run it, it immediately closes and says null pointer exception and the line "String temp = ((String)copy.get(i));" is highlighted, never had this happen before either
ok well now i think im understanding this better, but now im getting an illegal start of expression for the beginning line of my sort method, why is this happening after adding the new line?
ok expert programmers, after a couple more hours of debugging it seems ive hit another wall, now again I have no more syntax errors but when trying to run it it comes back and says out of bounds error on the line "String temp = ((String)copy.get(i));" which i think it probably means is trying to access the first slot of the array list but there is nothing there which i dont get because ive created the sort method and then called it. But it wont even let me input anything before it closes which is probably why there isnt anything there, here is the new code
public static void main() {
int i=0, thesame ,size;
ArrayList<String> list = new ArrayList<String>();
Scanner input = new Scanner(System.in);
String bString = "done";
for(i=0;i<0;i++){
System.out.println("Enter a name");
>>27
jesus, as i said im really crappy at this, im trying not to sound so stupid, I have been doing this program forever but i dont understand why im getting an out of bounds exception now, jesus im sorry im not a professional quality programmer, im not saying you have to help me but im not a troll, just retarded when it comes to comp sci i guess
Name:
Anonymous2008-03-16 15:24
op here again, there is probably just one simple concept or something I am missing, correct? I'm sure once i figure this out I will understand much better.
Name:
Anonymous2008-03-16 15:26
>>29
Why should I believe a troll? gb2trollland, troll.
Name:
Anonymous2008-03-16 15:26
>>29 professional quality programmer Proprietary customer-oriented solutions
Name:
Anonymous2008-03-16 15:29
Established in 1997, Enterprise Solutions is 100% focused in providing customers with the best infrastructure solutions available in the marketplace. We architect, design, supply, install and maintain scalable enterprise solutions within your required timescales and budget to enable your business to grow.
Name:
Anonymous2008-03-16 15:30
Enterprise Solutions can design, maintain, upgrade and support solutions that enable you to centralise the management and storage of your information. As the volume, complexity and importance of your data increases, Enterprise Solutions can also provide you with seamless scalable solutions to manage and protect new elements without the need to upgrade your infrastructure, all at a fraction of the time, effort and expenditure required by simply implementing separate products.
Name:
Anonymous2008-03-16 16:57
Well thanks for the help anyways guys, ill just keep fiddling with it i guess
Try stabbing yourself in the chest. I've heard that works.
Name:
Anonymous2008-03-16 19:33
>>29
You declare thesame as an int, but never use it. Remove it. It's only there to confuse it with the boolean theSame.
You declare int size, assign the size of the array to it, and then never use it, instead using copy.size().
In if (theSame = true), you're using an assignment instead of a comparison. Assignment returns the value being assigned, so the net result is that -1 is always assigned to i.
Not that it matters, since the for loop it's in will never execute, since i starts out as 0, which is not less than 0.
But seriously, don't add to ArrayLists using indices directly unless you have to. The entire point of ArrayList is that it deals with that stuff itself.
And when retrieving yours Strings from it, you don't have to cast to String, since you're already using generics. You don't even need that temp variable. Just pass it directly to System.out.print().
And that's just some of what's wrong with your main method. I'm not even going to look at the other one.
If you aren't a troll, get the fuck away from computers right now. You're never going to be an even halfway competent code monkey, let alone a real programmer.
If you do intend to stay in this field, at the very least learn to format your fucking code, so other people can clean up after you.
Name:
Anonymous2008-03-16 20:22
>>37
oh wow, some of those mistakes are just retarded on my part, i was writing this at like 3 in the morning yesterday, thanks though ill keep working from there