This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Getting error please see and help it... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting error please see and help it..." Watch "Getting error please see and help it..." New topic
Author

Getting error please see and help it...

Supriya Dle
Greenhorn

Joined: Feb 12, 2009
Posts: 3
Hi,

I am new user of java & I will doing my teaching with Kathy Sierra & Bert Bates book (Head First Java)...
Today I am solve one program but getting error code is Below mention:
// Code
public class DooBee {
public static void main (String[]args) {
int x = 1;
while ( x < 2 ) {
System.out.print("Doo");
System.out.print("Bee");
x = x + 1 ;
}
If (x == 2){
System.out.print("Do");
}
}
}


Need output like this "DooBeeDooBeeDo"

Can any body help me?
teja dharma
Ranch Hand

Joined: Feb 07, 2009
Posts: 51
public class DooBee {


public static void main(String[] args)
{
int x = 1;
while ( x < 3 ) {
System.out.print("Doo");
System.out.print("Bee");
x = x + 1 ;
}
if (x== 3){
System.out.print("Do");
}
}
}


SCJP 5
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Or preferably x should start at 0, and otherwise the program should stay as you originally had it. You're going to have to get used to counting from 0 -- that's how it's traditionally done in Java and most other programming languages.


[Jess in Action][AskingGoodQuestions]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37926
    
  22
Welcome to JavaRanch
What happens if you miss out the if (x == 3) test? Does it make any difference to the output?
Supriya Dle
Greenhorn

Joined: Feb 12, 2009
Posts: 3
Hi All,

Thanks...

When I am using below coding:

public class DooBee {
public static void main (String[]args)
{
int x = 1;
while ( x < 3 ) {
System.out.print("Doo");
System.out.print("Bee");
x = x + 1 ;
}
If (x == 3){
System.out.print("Do");
}
}
}

"Getting error "DooBee.java:10: ';' expected
If (x == 3){
1 error"

And when I miss "If (x == 3)" then the program run sucessfully.... thanks Really grate experince in this forum...


Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37926
    
  22
Are you writing "if" or "If"? Please use ctrl-C ctrl-V to quote code if possible.
mansi gupte
Ranch Hand

Joined: Dec 30, 2008
Posts: 72
Supriya Dle wrote:Hi All,

Thanks...

When I am using below coding:

public class DooBee {
public static void main (String[]args)
{
int x = 1;
while ( x < 3 ) {
System.out.print("Doo");
System.out.print("Bee");
x = x + 1 ;
}
If (x == 3){
System.out.print("Do");
}
}
}

"Getting error "DooBee.java:10: ';' expected
If (x == 3){
1 error"

And when I miss "If (x == 3)" then the program run sucessfully.... thanks Really grate experince in this forum...




Hi,

The error is a syntax error, java's keywords are case sensitive use if and not IF or If and the program would run fine
Supriya Dle
Greenhorn

Joined: Feb 12, 2009
Posts: 3
Thanks...

I have learn new things from you guys...!!

I will keep in mind from next time...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37926
    
  22
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting error please see and help it...
 
Similar Threads
JVM-Error: "cannot read: incdem.java
Really beginner question
Exception in thread "main"
Java error
While loop - Head's First Java example