Most answers for [java] and [jvm]

Architect for Chronicle Software http://chronicle.software

Blog has had 3 million hits http://vanillajava.blogspot.com

Java Champion

5h
comment Change method's return type dynamically
@IvanSadovyi that is what the cast is for.
5h
comment Change method's return type dynamically
@IvanSadovyi the compiler will only let you call a method it knows the object implements. You could use reflection but that would be more complicated.
5h
comment Change method's return type dynamically
@IvanSadovyi the compiler has to determine that the method can be called at compile time. This means you can only call a method which the compiler knows you can call.
5h
comment Change method's return type dynamically
@MasterMind You only need to override the methods where needed.
6h
answered Change method's return type dynamically
6h
comment Change method's return type dynamically
interface A must have animate1() and animate4()
6h
answered Invocation of contravariant methods in Java
6h
comment How can one class change another class value without the original class object
@Nexima360 A common source of confusion is that X num is a reference and this reference is passed by value, but it is a shallow copy allowing you to change the X object which has been referenced. This means x.num can be changed but x cannot be changed for the caller.
6h
comment Palindrome for Integers and Strings Java
Please don't use StringBuffer as it was replaced by StringBuilder more than ten years ago. Note: you also use StringBuilder.
6h
comment Java program that gets 10 int number and calculates the average with a loop
What is the trouble you are having? I am have trouble understanding what the problem is. In fact you can google "java how to I loop 10 times" and get answer for exact 10 times if you can't image how to write such a loop for yourself.
6h
revised java 8 i/o stream application
deleted 91 characters in body
6h
answered java 8 i/o stream application
6h
comment How to get a double data type in Java?
In primary school we learn integer division where say 22/7 is 3 with 1 remainder, but I find most adults forget this, but it makes sense to my 11 year old.
6h
comment Instantiating two instances of a class
I used to think that a getter was so trivial, it wasn't possible to get it wrong, but I stand corrected. I suggest you use your IDE to generate the getters. A getter just gets the value i.e. returns it. It doesn't do anything else and it's not static.
7h
comment How can I concatenate multiple ArrayLists into one?
@MichaelG sum being the index I was looking up and the index is the sum you want to print.
7h
comment java-beginner: Adding to an ArrayList
That is what your code does, if you wanted it to do something different, you need to say what that is and write the code to match what you want it to do.
7h
comment How can I concatenate multiple ArrayLists into one?
@MichaelG you need to use countList.get(i) just like I did in my answer.
7h
answered How can one class change another class value without the original class object
7h
answered What's the point of java.io.BufferedWriter.min(int a, int b)?
7h
comment How can I concatenate multiple ArrayLists into one?
@MichaelG yes, you want to a loop which counts from 10 to 60.
1 2 3 4 5