Win a copy of Head First Android this week in the Android forum!

Olga Matveeva

+ Follow
since Jul 21, 2015
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 Olga Matveeva

Campbell Ritchie wrote:Yes, HFJ does cover Java5. Which page?

395, Be the compiler exercise.

How could I pass b without making listener an inner class?
6 years ago

Go back to Eclipse or whichever IDE you have and look for the compiler errors, shown by red triangles on the left of the code. If you hover the mouse on the, you will get details of the error and even how to correct it.

This was exactly the thing. Error was saying that b cannot be resolved and I couldn´t understand what did that mean.

Is the listener class supposed to be a top‑level class or an inner class? I suspect it should be an inner class, but you have made it a top‑level class.

Yes, you were right. I mistakenly created listener as a separate class instead of creating it inside the InnerButton class. I fixed that and it solved the problem. Thanks a lot

Campbell Ritchie wrote:Which book are you using? Does it cover Java5?

I am using Heads first Java, 2nd edition.
6 years ago
Hello all,

I tried the sample code from a textbook dated 2005 year while learning Java, but it gives me errors which I do not understand how to solve. Would really appreciate your help.

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "JFrame", import expected
Syntax error on token "JButton", import expected
b cannot be resolved
b cannot be resolved
b cannot be resolved

at BListener.<init>(
at InnerButton.go(
at InnerButton.main(
6 years ago

Jesper de Jong wrote: It's all quite straightforward. Is my explanation clear enough, or do you have any more specific questions about this?

It is quite clear and you explained that by definitions of Java machinery. Thanks a lot!

I could also think about going deeper and asking "why is it exactly so", but not quite sure that my question would have a point... Because in general it is how that language is created, right?
6 years ago
Hi All,

I am completely lost in the logic of execution of that sample code. Could anyone explain what´s going on there, how order of execution is like that?

The output is

super static block
static block3
in main
super constructor
6 years ago

Tapas Chand wrote: But I was referring to the study days (we were not allowed to use any IDE, did learn core java using edit plus )

Ah, I see
I started this course as well only using the TextEdit and command line. It though required sometimes changing a bit the structure of the code, because the way exactly it was done in the book, it was not always processed by javac.

But then I changed to Eclipse, for me it seemed not to be anyhow harmful for the learning process. Are there any reasons actually to stay with plain text code writing?
6 years ago

Tapas Chand wrote:I remember in our study days, teachers insisted on copy/pasting as much as possible instead of writing the names to avoid this kind of mistakes.

Oh, come on it made me go through the logic of code again and through the chapter, making that course material to become an active part during that troubleshooting. If I was just to copy the code, that would be the same as reading it and forgetting soon after. Of course I would rather modify the example code to create smth new on top of it but it might be just a bit early for me. Most primitive mistakes are corrected by IDE itself, but in that case this was mistake not in spelling the command, but the variable title. Absolutely legal I would say, but changing the design.
6 years ago

Campbell Ritchie wrote:Welcome to the Ranch

Your code was horribly difficult to read, so I added indentation and code tags.

Sorry for that. Just joined and havent learned to use that option yet.

Campbell Ritchie wrote: Did you use a word processor (=WP)? Never use a WP for coding because they may introduce control characters and smart quotes which will upset the compiler.

No, I was just a bit lazy to copy a distributed pieces of code from their respective class tabs from Eclipse and placing respective curly brackets, so easier was to copy from book. But there is no spelling error in my version, I was not coping the code, I was writing it before checking with the solution and then corrected the mistakes. So the only mistake I am getting is the one mentioned - in Eclipse it says that "The type Clowns must implement the inherited abstarct method Nose.iMethos()".


Yes, this was the spelling mistake in 1 letter. Gosh you were right. Thanks a lot!

(So, this was the mistake in 1 letter in the method in Picasso, so instead of a method from interface being implemented, there was just a new method created, and thus the subclass was not in fact inheriting any implemented methods from its superclass.)
6 years ago
Hello everybody,

question appeared while solving PoolPuzzle from Heads first Java on page 265.
I use Eclipce to write and run the code.

The code is that one below (all classes in respective tabs for Eclipce, below is just a copy from book).

Question is the highlighted string. The IDE says that there is an error, because abstract method from the interface (which is called Nose) must be implemeneted; technically, it IS implemented in the Picasso which is superclass for Clowns (Clowns extends Picasso). BUT for some reason implementation is not happening and the IDE returns that Clowns must implements abstract methods. Any ideas how that can be? Anything wrong there?

6 years ago