Adam Chalkley

Ranch Hand
+ Follow
since Nov 27, 2013
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Adam Chalkley

Hey guys,

for the past year mainly I have just been using C++,I have taken a slight detour from Java reason being this year my course focuses more on C++ rather than Java which was the first 2 years,

my question is not really a technical question but more so an opinion based one,So since this is a Java forum why do you prefer Java over other languages?

I can see some advantages such as Javas garbage collector,no out of bounds array indexing and mainly the JVM which is a huge plus.

There are some notable difference between C++ and Java,such as Java seems to create all objects on the heap where as in C++ you can declare objects on the heap or stack,operator overloading does not exist in Java,C++ makes you manage your own memory,Java does not have structs,In Java everything must be in a class so does not support functional programming.

What makes you choose Java over languages like C/C++?

There are some things I like and dislike,the thing I like about Java as I mentioned is the JVM something I don't like is it's swing and AWT gui libraries the layout manager is quite tricky and a pain to get right.

So with C++ being a faster language in general and having more options what makes Java appealing? I mean both languages syntax wise are almost identical and I would say it's actually not too hard to make the switch from one to the other.

In the future I plan on making android apps which are mainly Java based.

but if you were writing a desktop which language would you generally choose C++ or Java?

3 years ago
much appreciated Knute,it's been a while since I have touched Java
3 years ago
wow that was the problem,such a simple mistake overlooked :/

thanks Knute
3 years ago

Knute Snortum wrote:What's line 33 in the original program?  It looks like you removed the import statements which changes all the line numbers below.

line 33 was

3 years ago
also I tried a bit of debugging to see if the array list grew when I called the addUser() function and the size did increase so I have no idea why I would be getting a null pointer exception :/
3 years ago

Knute Snortum wrote:Well, the stack trace and the error message would really help...

error message : twoException in thread "main"
at Main.main(

the stack trace doesn't seem to be printing maybe I've got something wrong?

3 years ago
Hi guys,

It's been a while since I've coded in Java I seem to be getting a null pointer exception but can't seem to figure out why.

any idea why this may be happening?

3 years ago
Thanks Campbell,

yes long time no speak , I have been mainly focusing on cyber security/ forensics as I have a few repeat exams in them in August,

not much programming mainly static and dynamic analysis of malware but also cryptography,and pen testing(using different frameworks such as metasploit/nmap armitage etc)

the little programming that I have been doing since is mainly with C / C++ but I feel like now having a better understanding of C++ will help me with Java aswell.
3 years ago
First off I am happy to be back I have not posted in almost a year,took some time off to focus on other aspects of the computer science field but I have been programming quite a bit just not learning much new stuff,

any who,I have a question and I couldn't find much answers online,how are GUI components such as a JButton or Jframe implemented??

are they written in assembly language,surely you cannot just create GUI components out of nothing,I am guessing assmebly is used,

and if so how is the assembly used to create them?

anybody have any links to how these components are created in code??

3 years ago
thanks guys

yeah very true I could have simplified it with one line of code thats something I need to get a hang of

and wow thanks Campbell nice implementation I will try to use that going forward

much appreciated
3 years ago
also thanks Carey nice spot
3 years ago
thanks for the replies guys that rhymes

by calling the method in the catch block it seems to have solved my problem

I know in C++ you have to do something similar because the buffer is put into an error state so you need to clear it and reset it to a normal state is it similar in java?

is that why we need to call the .next() function?

to sum it up why do we need to the the .next() function if an input mismatch occurs?

3 years ago
Hey Campbell

I simplified it a little and made a utility method to check for the correct range

but still in my try catch block I get stuck in an infinite loop the same thing occurs it keeps printing invalid 2 and choose a row

3 years ago
Hi guys I have run into a snag with my tic tac toe program,

I seem to be stuck in an infinite loop when I enter a letter instead of a number so If I type in a it will keep telling me invalid input 2 and below it will show choose row but does not let me input anything in,

anybody know why I'm stuck in an infinite loop?


3 years ago