This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Kevin Mckeon

+ Follow
since Jan 17, 2018
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 Kevin Mckeon

How many times will the following code print "Hello World"?

A. 9
B. 10
C. 11
D. The code will not compile because of line 3.
E. The code will not compile because of line 5.
F. The code contains an infinite loop and does not terminate.

this is my interpretation :

First iteration
i is equal to 0,
i is reassigned as itself (still 0)
i is incremented by 1 (i is now 1)
Print Statement

Second iteration
i is equal to 1,
i is reassigned as itself (still 1)
i is incremented by 1 (i is now 2)
Print Statement

10th iteration
i is equal to 9,
i is reassigned as itself (still 9)
i is incremented by 1 (i is now 10)
Print Statement
: end of loop

However the correct answer is F which I cant really understand

F. In this example, the update statement of the for loop is missing, which is fine as the
statement is optional, so option D is incorrect. The expression inside the loop increments
i but then assigns i the old value.
Therefore, i ends the loop with the same value
that it starts with: 0. The loop will repeat infinitely, outputting the same statement over
and over again because i remains 0 after every iteration of the loop.

1 month ago

Dave Tolls wrote:Well, the first thing I can think of is testing.
Unit tests, especially if defined beforehand (Test Driven), would help you know if your code fulfills requirements.
I can think of some edge cases that might cause issues with your code, eg what happens if the user doesn't enter a valid accountNumber?

Thanks for the advice, Ive never really done testing apart from trying out a few inputs and checking i get the right answer.

Is there a particular method, plugin, or system to fully test this kind of a program ?

Or is it always a manual process of thinking up a set of test cases and keying them in one by one
1 month ago
Hi Guys,

Im good at java but when self learning its hard to know if the classes and methods you create are designed properly.

I've created an ATM application that contains 3 classes, and

The App creates an ATM class (which in turn creates multiple Account classes) and requires user input to choose an account number then choose to view, withdraw or deposit funds

From the point of view of Abstraction, security, and best practice etc, can anyone advise what I should look to impliment, any relevant articles or courses on class design or general pointers

1 month ago

I have an ATM class, that simulates an ATM. When this class is created in my App, it populates an arrayList with a set of account objects

Im trying to access an account object within this arrayList and return the balance of that account

Here is my ATM class

and here is my account class

Im able to access the slot in the array that has an Account, but how do I access the methods of that particular account object
1 month ago

Kevin Mckeon wrote:

Knute Snortum wrote:Does the class you're running have a main() method?

Is a valid class -

and this class uses the Stopwatch class which has a constructor and a couple of methods.

I think the problem has to do with my run configuration.

I forgot the [] from the main method. Its not as valid as i though. case closed
1 month ago

Knute Snortum wrote:Does the class you're running have a main() method?

Is a valid class -

and this class uses the Stopwatch class which has a constructor and a couple of methods.

I think the problem has to do with my run configuration.
1 month ago
I did a project last week using struts and tomcat, which all worked fine

This week, I made a new project in my workspace with a few simple classes as I am practicing a few basic Java concepts

Every time I try to run my simple class, I get the message "The selection did not contain any resource that can run on a server" (although I'm not even fully sure which class its trying to run!)

I've tried changing perspective from JaveEE to Java, and I've tried to "Run As.." but this only brings up " run on mobile browser Simulator
1 month ago

Campbell Ritchie wrote:€1200 is no slight sum if the course isn't any good. Have you phoned to ask for more details? How does that material match your current skill set? Can you get more practice by other methods, e.g. creating projects, or frequent posting on this sort of forum?

Im beginning to feel now that neither course would be worth doing.. There is a huge difference between the courses I'm talking about and the beginner / intermediate / advance course I have found online :

Beginner -
Intermediate -
Advanced -

(This course is somewhere in the USA, but I'm just using it as a comparison)

Also a 3 hour lecture for 11 weeks isn't a lot of class time (bearing in mind not all material will be new). I would say I've touched on about one third of the material from each of the evening courese

Maybe my €1200 would be better spent on a solid book, a laptop upgrade, a few concentrated Udemy courses and self study plan/project that I implement over 12 weeks or so.
1 month ago

Stephan van Hulst wrote:If you're not a beginner, both courses look a little disappointing, looking at the topics they could be about instead. For instance, in the first course, the topics of concurrency, and networking would be much more interesting than the topic of collections.

Are these courses offered by different institutes? Are they set up the same way? How long do the courses take? What is your own take on these two?

Im not a beginner but my programming knowledge is a bit dis-jointed. For example, I've done personal projects on reading in and analyzing large text files via streams but I've never used Inheritance, Polymorphism, Abstract Classes, Interfaces, Enums, etc except in theory.

The courses are in different institutes, both cost about €1200 ($1481) both are a 3 hourly class a week and run for 11 weeks.

At first I was hopeful but now I think that the courses will be too easy. the "Advanced" title only seems to me to means that it is a little more advanced than absolute beginner. On the other hand. Im doing very little Java in my current job and need to keep it fresh in my mind 
1 month ago
Hi all,

I’m considering doing a evening course in advanced Java development to keep my skills sharp. I’ve come across two Advanced Java courses where the course content differs.

One course looks to be about using java practically where as the other appears to be more about advanced topics in the language. My current level of java is about enough to pass the Associate certificate exam and my current position isn’t really giving me much exposure to as much java as I was hoping .

At the moment I'm working as a full stack web developer but doing very little actual coding.

Course summaries are below, hopefully someone can give me a few pointers to which one would be more relevant \ advantageous (I've put a tick beside areas I've touched on in the past)

Course 1
   Files and Streams
✓ Collections
✓ Generic Collections
   Java 8 Lambdas and Streams
✓ Generic Classes and Methods
✓ Databases and JDBC
   Web Applications1
   Web Applications2

Course 2
   Aliases and Cloning
✓ Inheritance
✓ Abstract Classes
✓ Interfaces
✓ Packages
✓ Nested
✓ Classes
✓ Inner Classes
✓ Variable Scope within Classes
✓ Ordered Lists
✓ Dictionaries/Maps
   Internal and external libraries
   Design of libraries
   Library implementation & packaging
   Error handling
   Boundary Conditions
   Unit testing
   Object decomposition
✓ Model-View-Controller
✓ Introduction to relational databases
   Access & manipulation of relational database
   Optimisation & efficiency
   Client considerations
   User interface
1 month ago
Here is a snip of code

From my understanding, this is the package structure is

If this is the case, What does the statement import aquarium.* do ?
1. Will it import both water classes ?
2. Will it throw an error because its conflicts with the structure package1.package2...packageN.Class when it finds the nested jellies package?
3. Will it simply import the Water class from the aquarium package and ignore the nested jellies package

I believe that number 3 is correct because 1 is impossible but I don't understand why 2 is not correct. For example if the class aquarium.Water didnt exist, then 2 would be correct ?
2 months ago

Knute Snortum wrote:First question: Java is case sensitive.  You have "WaterBottle" and "Waterbottle."

Its been a long week

Knute Snortum wrote:

Second question: In your second Main class, "empty" and "full" are local variables and must be initialized before they are used.  In the class Waterbottle, "empty" and "full" are instance variables and are given default values.

Thanks, this makes sense. I'm beginning to understand what an instance variable is. In that case, whats the difference between an instance variable and class variable ?
2 months ago
Can anybody tell me why I get an error when creating the Waterbottle object if my Waterbottle class is in the same file (if the Waterbottle class is in a different file, it works fine)

My second question is that (if the above code is fixed), how come this snippet will not work as it essentially called the same initialized variables

2 months ago