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
>>40
Post some more of your code and I just might.
Name:
Anonymous2008-03-16 20:48
Op here, I think I might actually switch my major to something that will actually land me a decent job that actually pays good, requires good social skills and strong math, and doesn't have the shit being outsourced out of it.
There are two people on /prog/ who know enough Java to help you. Fuqin angering them isn't in your best interest.
In other words, back to /b/, please.
Name:
Anonymous2008-03-16 21:04
/prog/ has been dead for a while now, seriously, its a programming board, the place where the cancer killing society(i.e. socially retarded fatasses who contribute little to the world) can gather and feel the illusion of being elite some how, yes op the comp sci industry is a joke at the moment and probably for a LONG time, you will get an entry level programming job and go nowhere, i suggest if you are good with the math just major in math and go into high level finances, work for big coorperations or something, if you are indeed good at math and have reasonable social skills you can pull it off, steer clear the of comp sci for now though, take it as an elective if you want, i dont think you suck at programming, i mean ya you do, but everyone does when they start
Name:
Anonymous2008-03-16 21:05
>>52
op here, as i said im not the one being a douchebag, those people arent me
Op here, I loved my last comp sci class as it was based in c++. I was great at it and I ended up with an A in the class, but so far java just seems like a pain in the ass language that has no benefit unless i want to make little faggy applets, of course since im new at this im probably wrong but it just seems that way right now which is really turning me off from computer science
Name:
Anonymous2008-03-16 21:09
>>53
Inb4 nobody responds to this because they are scared of the truth
Name:
Anonymous2008-03-16 21:13
>>58
we know that it is true, but i do it for the passion of programming, ya I probably will never make too too great of money but I love to program and thats all that matters
Name:
Anonymous2008-03-16 21:13
>>57
If you approach Java like Sepples you're going to suck royally at it. It may not be perfectly OO, but it's still a fuck of a lot more OO than Sepples, and it requires a different style of programming.
Though the mistakes in the code posted here are so very basic and not specific to Java I doubt OP has ever programmed in anything except maybe BASIC.
>>58
Read the FUCKING HATE REDDIT thread. I don't feel like repeating myself.
Name:
Anonymous2008-03-17 3:32
>>57
Applets are so last century ...
The only reason for doing anything with Java is that the GUI programming is far less of a PITA than it is in C++
Nowadays with Jython/JRuby/Groovy/Scala... running on the JVM, it doesn't have even that advantage, since they all call into the same APIs
Name:
Anonymous2009-03-06 7:37
The file you could try some hackery involving the overloaded.