• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Trying to figure out what those mean

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im new to java, learn it couple weeks ago n im confuse about the following error.

';' expected
')' expected
identifier expected
cannot find symbol

what does those mean?
thanks for helping in advance.
 
Marshal
Posts: 74342
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have several error messages and can't immediately work out what they mean go to the very first error message, sort that out and try again. Sorting the first error can sometimes remove several error messages.

The first two messages usually mean you have got your ) or your ( or your ; in the wrong places. Don't use NotePad, get something like NotePad++ NotePad2 or Jedit and use them as text editors. When you tell them that you are editing a .java file, they usually implement bracket highlighting. If you put your mouse on a ( or [ or { the other half of the pair changes colour. Then you can easily see whether your () [] and {} are correctly paired.

The ones about cannot find symbol might mean that you have misspelt a variable name, put in a method name without () or with the wrong number of arguments. Or you might have a local variable which has gone out of scope.

The bit about identifier expected could mean anything. If you can't understand what has gone wrong when looking at the code, see whether you have mistakenly used a keyword. If you have a method which increases the value of something by 2, this method heading will cause that error message:

public void double() . . .

There is a page with error messages on here; see whether that helps.
 
Campbell Ritchie
Marshal
Posts: 74342
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good luck with the errors, and welcome to JavaRanch
 
Jian Zhi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wow.. that was a fast reply n thanks for the welcome.ok, i couple question here.

1)
Im using jGRASP version 1.8.4. for my java app, is that a good program?

2)
I did a program bout inheritance, as following..


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
but the problem is the bold part, it shows null, 0, 0, 0 for everything except for the extraCharge.The child class couldnt get data from the parent class. how do i fix that?
[edit]Add code tags and a few additional "newlines." CR[/edit]
[ November 08, 2008: Message edited by: Campbell Ritchie ]
 
Campbell Ritchie
Marshal
Posts: 74342
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't used jGrasp for a long time; I have forgotten whether it supports bracket highlighting etc.

You ought to have used a separate thread for the 2nd question, since it is a new question. Please always maintain indentation and use the code button; I have edited your post so you can see how much better it looks.

Neither of your Order classes appears to have a constructor, and the format of your set methods is very unusual.
If you create an object and don't initialise all its fields, they will have values of 0 false or null. That can cause nasty errors later on, so you should always make sure every field is initialised. Read this section of the Java� Tutorials.
 
Jian Zhi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry bout that >.< n yes it does look better.

constructor is the 1st thing that runs in a program right?
is it a must?

by unusual, you mean its wrong? then how am i suppose to put it?





this code is suppose to use the getCustomerName() function in class Order right? or should i declare a String name n write as :

 
lowercase baba
Posts: 13013
66
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

constructor is the 1st thing that runs in a program right?


no. For a java program, the first thing that runs is the main() method. In fact, it's the "public static void main (String [] args)" method.

it is possible to write an entire java program that NEVER calls a constructor.
 
Campbell Ritchie
Marshal
Posts: 74342
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it is usually best to have the constructor run when you create an object. I presume you have seen the examples in the Java Tutorial I posted earlier. You could put those JOptionPane calls in the constructor, and use no arguments, as an alternative.

You will probably have seen the usual format for set methods in the Java Tutorial too. People using your classes will expect "set" methods to follow the usual pattern.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic