David Marco

Ranch Hand
+ Follow
since Feb 23, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by David Marco

I found myself the answer to the above "too elemental" question. If I want broken lines, I must insert a <br> tag after each println invocation within the for-each loop, due to println only writes in the response object, but do not format such a flow with implicit new lines. Sorry for waste your time.
15 years ago
JSP
When I try to do a foreach loop inside doPost or doGet like this:

why the browser outputs all the values together in the same line (like an out.print()) ?
15 years ago
JSP
I have been preparing for three months (three hours per day), last fifteen days taken mock sxams. I'm surprising for the exam format: 60 questions, pass score 58% (in Examlab the format is of 72 questions and pass score 65%). The exam is not easy, but not too hard, the questions are short but tricky. You need stay in good shape to take it.
15 years ago
I cleared yesterday SCJP 1.6 with a score of 80%. Thanks to everyone for your invaluable help all the time.
See you in SCWCD forum!
15 years ago
As Karthick said, early binding must be the solution, so the call is resolved at compile time. Thanks to everyone.
Karthick main() cannot instantiate a inner class directly because you need a reference to the outer class prior, so:

is equivalent to:

and "this" cannot be called from a static context

I'm thinking about my first post and my thought is that on runtime the VM tries to call the last method available from top-down the inheritance tree, so when it finds the superclass private method, it stops and points that method for the subsequent call. Please correct me if I'm wrong or not accurate.
I'm in little surprise by the behavior of the below code (write my own):

I'm wide aware that inheritance doesn't apply to private methods and that private members on top-level classes are reachable by regular inner classes, but shouldn't the VM call the Sub.callMe() method on runtime, independently (pass through) of the non-polymorphic condition, based on the real object type? Why the superclass version is called at runtime if the object on the heap has a method with the same signature "nearly"? Is the call ABSOLUTLY defined at compile time maybe?

Thanks in advance.
Thanks Bob and Peter, I really misspelled the method name.
I'm unable to understand why this program (coded my own) don't work:

If I change line 38 for this:


Then the program runs succesfylly. I'm going crazy!!

I learned that one source file there will be one public class and it would be class containing main method


The last is wrong. A file can contain only one public class, and the name of the file must match the public class name if any. But another class can contain the main method. In fact, ALL the classes in a file can contain a main method and you can execute anyone of them after compile the .java file.

Greetings.
Duc, I thought the same two post above, but I had to rectify quickly and erase all my post. The first line:

creates a new String object as says the Java API specification:

All string literals in Java programs, such as "abc", are implemented as instances of this class.


Furthermore the string literals are linked to the string literal pool (which contains only references to objects, not objects). The String creation on the heap is mandatory. I think the given answer is wrong.

fruits.toString().substring(1, fruits.toString().length - 1);


above code appears to create three string objects "from side to side" whereas


1. String str = fruits.toString();
2. str = str.substring(1, str.length - 1);


creates two Strings. Also the first solution leaves all the three objects unreferenced on the heap (a memory wast?) whereas the last solution only leaves one unreferenced String.

Correct me if I'm wrong.
15 years ago



Every time your code calls "new ..." write the reference variable name outside the heap, draw the object created (a square for instance) inside the heap, and link up both elements with an arrow. When a reference variable changes, write a new arrow from this reference variable to the new target, and CROSS OFF the original reference variable arrow. At the time to call System.gc(), those objects crossed off are unreachable (unaccessible from a live thread) and so eligible for garbage collection. Be care with more complex objects which might contain inner references to either other references or new objects. The key point is draw arrows from references to their respective objects and removes (crossing off) when references changes.

I hope this helps.
Bob this is what I wanted to hear. Thanks to everyone.