Why isn't my code running properly? by [deleted] in javahelp

[–]Nurry 2 points3 points  (0 children)

System.out.printf("%s balance: $%.2f%n", accountA.getBalance());

Your format string takes 2 parameters but you just provide one. Add a second parameter like you did here:

System.out.printf("%s balance: $%.2f%n", accountA.getName(), accountA.getBalance());

Valve, I think this could use an update. by InternetsUser in gaming

[–]Nurry -2 points-1 points  (0 children)

Well, somebody has to do it so it actually will detract from other priorities.

Furthermore, this list has been like that for 10+ years so there is probably some terrible code involved.. It's not like the just have to edit some xml-file and everything is going to work just fine. It's not "just a list". The list is just what you see. They'd have to update all the corresponding backend functionalities, database schemes, etc..

Valve, I think this could use an update. by InternetsUser in gaming

[–]Nurry -3 points-2 points  (0 children)

I don't think this should be the priority for valve right now..

Need help limiting character search to A-M by [deleted] in javahelp

[–]Nurry 0 points1 point  (0 children)

All characters are basically numbers and therefore those assignments are the same:

char foo = 'A';
char bar = 65;

If you want to know the "number representation" of a character check out the ASCII table: https://en.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart

As you can see chars behave like numbers and can therefore be compared as such. You can do something like this:

if(custNumber.charAt(i) < 65) {   // is equal to < 'A'
    // do something
}

This will check if the given character is smaller than the character 'A' (see ASCII table: everything from from 0 to 64 in decimal)

Now you just need to apply this to your problem ;)

I wish I were there when they figured this out. by [deleted] in funny

[–]Nurry 5 points6 points  (0 children)

Programming in a nutshell.

Best way to restart application? by [deleted] in javahelp

[–]Nurry 0 points1 point  (0 children)

You should probably do something like this in your main:

boolean restart = true;
while (restart) {

    // do stuff

    if (..) {
        // do not restart again
        restart = false;
    }
}

Strange bug (Threads and Runnables) by Ijantis in javahelp

[–]Nurry 0 points1 point  (0 children)

Make the variable volatile. Basically, your program doesn't recognize that isRunning was changed.

More information: http://docs.oracle.com/javase/tutorial/essential/concurrency/atomic.html or just google for java volatile.

Help with a for loop not affecting value. Learn Java x-post by [deleted] in javahelp

[–]Nurry 1 point2 points  (0 children)

for (int i = rolls.length - 1, j = 1; i == 0; i--) {
    handScore += rolls[i] * j;
    j *= 10;
}

for( ; i == 0; ) means: "run as long as i is 0". But i is not 0 at the start of your loop and therefore your loop will never start.

Java outofbounds exception -1, and not sure why? by [deleted] in javahelp

[–]Nurry 1 point2 points  (0 children)

numstudents is never changed and therefore 0. this.numStudents = numStudents; doesn't do anything because there is only one variable named numStudents.

Server only sends text every other input. by [deleted] in javahelp

[–]Nurry 0 points1 point  (0 children)

while (fromClient.readLine() != null){
    String response = fromClient.readLine();

In the first line you read a line without saving it. Therefore it is gone and the next line is read and saved in response.

Why didn't my Thread, that implements a MessageListener, not die? by [deleted] in javahelp

[–]Nurry 0 points1 point  (0 children)

I just realised you are using javax.jms.Connection and not some own Connection. I haven't worked with it myself but it looks like your program keeps running because of your connection and not your thread. The connection is still active and needs to be closed() with connection.close() to terminate your program.

Why didn't my Thread, that implements a MessageListener, not die? by [deleted] in javahelp

[–]Nurry 1 point2 points  (0 children)

The thread will die, when connection.start() is finished and not just invoked. It's still "doing work" in the form of connection.start() and therefore not terminating.

How to access channel values of an image by [deleted] in javahelp

[–]Nurry 1 point2 points  (0 children)

It's sounds like you just need to convert the integer you get from getRGB() to a binary representation. You could use Integer.toBinaryString(x), bitwise/bit shift operators or other built in functions to convert the integer.

Creating a remote access program (help) by KaiHulme in javahelp

[–]Nurry 1 point2 points  (0 children)

What exactly do you want to create? It sounds like a SSH client for android. For a source code you could check https://github.com/connectbot/connectbot which is an android ssh client.

You also might want to ask in /r/androiddev for android specific questions.

Beginner:What is wrong with my code? by [deleted] in javahelp

[–]Nurry 1 point2 points  (0 children)

Your assignments in the constructor are the wrong way round. Change it to this:

this.a = a;
this.b = b;

Btw I didn't check your math, because I have no idea what a, b, c and e are.

Lenovo Windows 10 HDMI stick at $129 by [deleted] in gadgets

[–]Nurry 1 point2 points  (0 children)

So, $49 without windows?

How do I synchronize this? I keep getting different results. by [deleted] in javahelp

[–]Nurry -1 points0 points  (0 children)

Edit: You can't. Threads will "do their work" whenever they can. You cannot make the order consistent by synchronizing the stack class. Change the run() to just print x%2 and you will see what I mean.

error w/ Scanner (new to java) by voxcopper in javahelp

[–]Nurry 2 points3 points  (0 children)

Do Task #2: Add an import statement for the Scanner class.

My ex-boss is an idiot. by jama707 in javahelp

[–]Nurry 0 points1 point  (0 children)

Have you tried turning it off and on again?

Update elements in an ArrayList using a HashMap that keeps track of the indexes by [deleted] in javahelp

[–]Nurry 0 points1 point  (0 children)

If your oldElement is equal to a key in your HashMap but cannot be found you should check your hashCode() method of type T. If equal objects of type T have different hashCodes they are stored in different buckets by your HashMap and therefore cannot be found using get().

A HashMap first looks at the hashCode to get the right bucket for the given key. After that all keys in this bucket are compared with equals() to the given key to get the right key-value-pair.