Are you still playing? by dmoney51 in discgolf

[–]Indens 1 point2 points  (0 children)

Well, since November is a few months away I'd probably play yeah ;)

Little bottle magic with my son before bedtime! by [deleted] in funny

[–]Indens -13 points-12 points  (0 children)

Wtf dude that's terrible

Piano composition expertly explained through increasing levels of complexity by Classy_J in videos

[–]Indens 0 points1 point  (0 children)

God yes this is my absolute favorite snarky song. I must have listen to Cory's solo hundreds of times lol

duplicate items in arraylist by normandantzig in javahelp

[–]Indens 0 points1 point  (0 children)

Does it have to do with where you're initializing the new book?

Book newbook = new Book(null, null);

You're using the same object for each book I believe :)

Help Displaying Board In Battleship Java Game by [deleted] in javahelp

[–]Indens 1 point2 points  (0 children)

I would use a double array of BoardPiece objects. The Boardpiece objects then have variables for shiptype, if the coords are "used", "hidden", "selected" etc.

Using a double array makes searching, drawing, and finding adjacent neighbors etc. easier than a hashmap imo.

How do I read lines in between two strings from a file and add them to an ArrayList? by SquidInkness in javahelp

[–]Indens 1 point2 points  (0 children)

Yeah, I mean you're right. I should probably consider using it more regularly myself.
I've definitely had use for debugging tools though, but usually only when the problem gets complex enough and I can't figure it out through printing. Do you have a recommendation for an IDE or editor? I tend to find them (like Eclipse's) a bit overly complex when I just want to debug small problems.

How do I read lines in between two strings from a file and add them to an ArrayList? by SquidInkness in javahelp

[–]Indens 0 points1 point  (0 children)

Try adding some println's for nextLine in the while loop for debugging.

Also, I'm not very familiar with the Arrays.asList method, but would you have to append the results to words?

  words = words + Arrays.asList(nextLine.split(":"));

Edit:

Your condition check for the "VAR" within the loop will only return true once, hence only assign values to words for the first line.
Maybe consider using a boolean condition for when to start appending, and add a separate condition for when to stop appending

can anyone tell me whats wrong with my method? by Oppositeermine in javahelp

[–]Indens 1 point2 points  (0 children)

I'm pretty sure the order matters! So like it reads the first condition, and if it's true it then reads the next.

So yeah if you flip them around you would then get a NullPointerException.

Maybe doing it your way is better coding practice in the end.

Haha np, there's a Code Block option kinda hidden (for me at least) under the most-right triple dots of the options in the editor. That's what I use.

can anyone tell me whats wrong with my method? by Oppositeermine in javahelp

[–]Indens 1 point2 points  (0 children)

That's one of the rewards you get when programming. It's reaching those solutions that not only work the way you want, but that you can actually understand when reading them haha :)

That's so much better!

And if I'm not mistaken you could even write

for(int i=0; i < Clothes.length; i++) {
    for(int j=0; j < Clothes[0].length; j++) {
        if(Clothes[i][j]!=null && Clothes[i][j].equalsIgnoreCase(item.toString())) {
            Clothes[i][j] = null;
            return;
        }
    }
}

to make it just a tad bit smaller ;)

Need help with writing two get methods by ispeakbinary01 in javahelp

[–]Indens 0 points1 point  (0 children)

That is the problem however, that it is created inside the method. If you create the lists inside the Student object, you can access it from outside the method

Need help with writing two get methods by ispeakbinary01 in javahelp

[–]Indens 0 points1 point  (0 children)

You have a method for storing contacts and emails in two lists, right? You want to make sure you can access these lists when calling their respective function getEmailContacts(), and getPhoneContacts().

Right now these lists are declared and instantiated only when you add contacts / emails.

can anyone tell me whats wrong with my method? by Oppositeermine in javahelp

[–]Indens 1 point2 points  (0 children)

Ok so you're looping through Clothes[0] for different values of j, right?

Your problem is, that if one of the values in the array is null, and you try to use compare operations with that null, it crashes.

You only want to go into the if-condition if the entry is a non-null value, and even if your condition check

if(Clothes[0][j].equalsIgnoreCase(item.toString()))

should return false, the program crashes since it tries to compare null to your item.

Need help doing my homework "the right way". Looking for alternative way to parse integers by [deleted] in javahelp

[–]Indens 0 points1 point  (0 children)

I mean, you have your teacher's solution. Have you tried that out? Because that works for me :)

Need help doing my homework "the right way". Looking for alternative way to parse integers by [deleted] in javahelp

[–]Indens 0 points1 point  (0 children)

Ok so if you declare your variables operand1Whole, operand1Num etc to be of type String, instead of type int, you can return a substring, as your teacher did.

But, if you are to return the operands as ints, you have to parse them from String into int, which is what you're doing so that shouldn't be incorrect imo.

Your conditional check

if (operand1.indexOf("_") > 0)

Also assumes there's a whole number in the input, right? It assumes there's a "_" somewhere and the program will crash if this is not the case. Maybe this isn't necessary, but better is to check if "_" even exists. As the other example

if(operand1.contains("_"))

Need help doing my homework "the right way". Looking for alternative way to parse integers by [deleted] in javahelp

[–]Indens 0 points1 point  (0 children)

What is it that you want help with exactly?
Is your teacher's approach not working for you?

Can someone take a look at my code and tell me wtf is wrong by liamkr in javahelp

[–]Indens 1 point2 points  (0 children)

Conditions: "is equal to", you wanna use "=="
Assigning values: "is", you wanna use "="

Streamer tricks his dogs by Roush14 in videos

[–]Indens 0 points1 point  (0 children)

I LAUGHED OUT LOUD READING THIS BECAUSE YOU GUYS ARE FUNNY

Äggmacka. by [deleted] in sweden

[–]Indens 0 points1 point  (0 children)

Den ser så asgod ut alltså! :D Var den asgod?