• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where can I learn SIMPLE explanation  RSS feed

 
Viv Richard
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started JAVA. I have some programming experiences. I started reading and doing codes from "Headfirst JAVA" book. Rather than just reading the code I have been trying even the examples in the book and trying to compile them. But at this stage of my learning, I have very limited knowledge; especially when black command console shows me an error. I don't understand what type of error it's referring to. The book talks about API reference. But when I go in there, API seems to be some links between thousands of things with little explanation. Besides, when I look at API references, if I don't understand one or 2 links in that API, I don't even get the answer of what I was looking for in that API.

??)Is there any simpler way or any place I can find explanation of the error(s)?

For example: herebelow a small code I copied exactly from the book and wanted to compile it.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Public class loopy
{

public static void main( string[] args )
{

int x = 1;
System.out.println("Before the Loop");

while (x <4)
{

system.out.println("The value of x is" + x);
x = x + 1;

}

System.out.println("This is after the Loop");

}



}

>>>>>>>>>>>>>>>>>>>>>

after I typed javac loopy.java this was the error in console:

C:\>javac loopy.java
loopy.java:1: class, interface, or enum expected
Public class loopy
^
1 error

>>>>>>>>>>>>>>>>>>>>>>
Now my question is even if book's example doesn't compile, what might happen to the exercises at the end of all chapters?

Help me out reading the error from left to right...
loopy.java:1 class, interface, or enum expected what exactly is it looking for and where can I get the explanation on this?

You might be sensing little frustration in my writing, but it's nothing personal against you. Any type of help would be appreciated.
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

after I typed javac loopy.java this was the error in console:

C:\>javac loopy.java
loopy.java:1: class, interface, or enum expected
Public class loopy
^
1 error


Java is case sensitive. It doesn't know what "Public" is.... I am sure you meant "public" (notice lower case p) which is an access modifier.

Henry
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And to answer to topic's question:
Where can I learn SIMPLE explanation

At the ranch ! Don't get frustrated, as you're only starting. Ask as many questions as you need here.
 
Viv Richard
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I corrected the "case problem", but now there is new problem after compiling. Could please you tell me what it's trying to say? after typing javac loopy.java in the command console, it's showing message like this:



C:\>javac loopy.java
loopy.java:4: cannot find symbol
symbol : class string
location: class loopy
public static void main (string[] args)
^
1 error

Could you please tell me what exactly it's referring to?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Viv Richard:
C:\>javac loopy.java
loopy.java:4: cannot find symbol
symbol : class string
location: class loopy
public static void main (string[] args)
^
1 error

Could you please tell me what exactly it's referring to?


Its the case problem again. This time it is with the string[]. It should be String[] (notice the upper case S)
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the code you posted in your first post, we expect one more similar error at the statement:

system.out.println("The value of x is" + x);


You will have to change it to

 
Viv Richard
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all of you for your support. As soon as I posted my last message, I diagnosed the problem myself and corrected. It's working fine now. And now I logged back on and saw few people already posted help.

Thank all of you once again. I will be back for sure if I have any other problem with code.

Viv
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As soon as I posted my last message, I diagnosed the problem myself and corrected.


Great going!

I will be back for sure if I have any other problem with code.


Sure. You will definitely find people, here, willing to help you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!