Results 1 to 11 of 11

Thread: Quick question

  1. #1
    Thumper is offline Member
    Join Date
    Dec 2009
    Posts
    11
    Rep Power
    0

    Default Quick question

    Hi I'm trying to run a simple programme and the code compiles fine but when I go to create the object I get the expected ';' error

    Here's the sample code I was given before I start to work on it.


    Java Code:
    /**
    * A class that maintains information on a book.
    * This might form part of a larger application such
    * as a library system, for instance.
    * @author (Insert your name here.)
    * @version (Insert today's date here.)
    */
    
    
    public class Book
    {
    // The fields.
    private String author;
    private String title;
    /**
    
    
    * Set the author and title fields when this object
    * is constructed.
    */
    // below is the constructor
    
    public Book(String bookAuthor, String bookTitle)
    {
    author = bookAuthor;
    title = bookTitle;
    }
    
    //methods to be inserted here....
    }// closing bracket for class definition
    /* End of Code */
    I can't create a new object from the above code is there an error somewhere on it?

    Thanks

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    806
    Rep Power
    6

    Default

    Ur code is fine.

    U should create an instance ...and have main method to run this
    1.Have a main method
    2. Create an isntance for Book class and call the method.

    Go thru Sun tutorial.
    Ramya:cool:

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Thumper View Post
    Hi I'm trying to run a simple programme and the code compiles fine but when I go to create the object I get the expected ';' error
    That is a syntax error and should be issued during compile time.

    kind regards,

    Jos

  4. #4
    Thumper is offline Member
    Join Date
    Dec 2009
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    That is a syntax error and should be issued during compile time.

    kind regards,

    Jos
    But when I compile in BlueJ there is no syntax errors reported

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Thumper View Post
    But when I compile in BlueJ there is no syntax errors reported
    Is the code from your orinal post the code you compiled? And tell us verbatim what the runtime error is when you try to run your code (if the compilation phase ended without errors).

    kind regards,

    Jos

  6. #6
    Thumper is offline Member
    Join Date
    Dec 2009
    Posts
    11
    Rep Power
    0

    Default

    Here's the error from the original code I posted



    But it complies without any error

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default

    So that's BlueJ!
    Blimey...

  8. #8
    Thumper is offline Member
    Join Date
    Dec 2009
    Posts
    11
    Rep Power
    0

    Default

    Well I finished off writing the rest of the code and one of the reasons what i can't create the object is because there is not default constructor.You have to make objects using two argument constructor or define a no argument constructor.

    Still getting the error but I know my code is right:confused:

  9. #9
    Thumper is offline Member
    Join Date
    Dec 2009
    Posts
    11
    Rep Power
    0

    Default

    No body here could spot with that picture that the text was missing "" around the string inputs???

  10. #10
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Thumper View Post
    No body here could spot with that picture that the text was missing "" around the string inputs???
    Nope, I don't work with that stuff so I didn't recognize anything from it. Don't expect others to work in a same environment as you are; and nobody should work with an environment s/he doesn't know from the inside out.

    kind regards,

    Jos

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Quote Originally Posted by Tolls View Post
    So that's BlueJ!
    Blimey...
    That was my reaction too, except that 'blimey' isn't a word I commonly use (the word I did use can't be posted here ;) )

    db

Similar Threads

  1. Quick Question...
    By FatalSylence in forum New To Java
    Replies: 4
    Last Post: 10-15-2010, 02:38 PM
  2. Really quick question
    By shadycharacter in forum New To Java
    Replies: 2
    Last Post: 04-22-2010, 10:06 PM
  3. quick question
    By vouslavous in forum Java Applets
    Replies: 4
    Last Post: 04-24-2009, 08:35 PM
  4. Hello everyone! quick question.
    By irishhokie in forum New To Java
    Replies: 5
    Last Post: 04-03-2009, 04:13 AM
  5. Quick Question
    By Spenc in forum New To Java
    Replies: 3
    Last Post: 09-22-2008, 02:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •