This week's giveaway is in the Spring forum.
We're giving away four copies of liveProject: Protecting User Data with Spring Security and OAuth2 and have Laurentiu Spilca on-line!
See this thread for details.
Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!

Alexander Visser

Greenhorn
+ Follow
since Dec 11, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alexander Visser

doubleValue() and hypot() are used now.
Must be different possible generic types.
The assignment asks for a generic Coordinate.
The exception is checked.
Thanks all for your help.
1 day ago
Now Coordinate extends Pair.
Constructor now use values t and s.
Created an own exception class, because this is asked in assignment. Indeed is NullPointerException also possible.
The assignment asks to implement Coordinate as Pair, so guess inheritance.
Indeed, my fault about generic types twice.
There is nothing written in the assignment about two generic types.
Changed getDistanceFromOrigin(), but doesn't work. Method hypot() gave problems indeed. What did I do wrong?
Thanks so far.

2 days ago
My home work so far now. Now I must implement a generic class Coordinate as Pair of two numeric (subtype of Number) values. The getDistanceFromOrigin method returns the distance from the coordinate to the origin.
I get stuck with the Coordinate class, what did I do wrong?

3 days ago
See code below I've tried, but b2 and b3 still refer to the same object. What did I do wrong?



3 months ago
Thanks for additional suggestions.
Hope I can make it more clear.
With class Book I can create a new book, for example "Java Development".
Within class BookCopy there must be two constructors.
First constructor is to create a new BookCopy with a book as parameter.
Second constructor is to create a copy of a BookCopy with a bookcopy as parameter.
If it is not clear, please let me know how I can make it more clear.
3 months ago
Didn't get any errors. But b2 and b3 both refer to the same object, but they must be different objects. For example: I have a book, named "Java Development" in the library and the library has 10 BookCopies of "Java Development". So I need to change public BookCopy(BookCopy bookcopy), so it will make a new object without referring to the same object.
3 months ago
3 months ago
I am trying to make a copy of a BookCopy.
I tried "return new BookCopy()" too, but doesn't work.
3 months ago
I have read a lot of articles about Java constructors with declaration in the same class. Now I got a little confused how to make copy constructors when attributes are declared in another class?

3 months ago
Output is now [MyClassToWest, MyClassToWest, null, null, null, null, MyClassToEast, null, MyClassToEast]
But must be [MyClassToWest, MyClassToWest, null, null, null, null, MyClassToEast, null, null]
1 year ago
Code beneath will explain code purpose.

1 year ago
Because in the assignment, MyClass2 goes to west and MyClass1 goes to east, that's why there's an if (array[i] != null) needed with additional code which is not implemented in this snippet to keep the code simple in this post.
1 year ago
How to shift MyClass2 as non-null value to right? Because MyClass2 is on the last position, this must be removed from the array and set to null.

1 year ago
Indeed a good suggestion. Thank you very much.

1 year ago
Array must be initialized with [-, -, -, -, -, -, -, -, -, -]
Then a few myClass objects will be added like [-, -, -, myClass, -, -, -, -, -, myClass]
That's why I need to fill the array with - first.
1 year ago