• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Quick question abouy Java method toString( )

Hello,
  I am a relative newbie to Java and I am working my way through a tutorial online.  I am getting an error on toString( ) that I just can't figure out.  Any ideas?

Error:

MusicStore.java:60: ';' expected
      Public String toString() {

//TestMusicStore.java

public class TestMusicStore{
      public static void main(String args[]) {
            MusicStore myMusic =  new MusicStore();
            myMusic.setOwner("Drew");
            System.out.println(myMusic);
            System.exit(0);
      }
}


//MusicStore.java

public class MusicStore {
      String Owner = "No Owner";
      String openMessage = "Yes, we are open!";
      String closeMessage = "Sorry, we are closed.";
      int openTime = 9;
      int closeTime = 21;
      
      
      void displayHoursOfOperation() {
            System.out.println("Store hours: " + openTime + "am to "+ (closeTime - 12) + "pm");
      }
      
      void setOwner(String Owner) {
            this.Owner = Owner;
      }
      
      void displayOwner() {
            System.out.println(Owner);
      }
      
      String getOwner() {
            return Owner;
      }
      
      int getOpen() {
            return openTime;
      }
      
      void setOpen(int openTime) {
            this.openTime = openTime;
      }
      
      int getClose() {
            return closeTime;
      }
      
      void setClose(int closeTime) {
            this.closeTime = closeTime;
      }
      
      boolean isOpen() {
         AltDate d = new AltDate();
            int currentTime = d.getHourInt();
            
            if(currentTime > openTime && currentTime < closeTime)
                  return true;
            else
                  return false;
      }
      
      void getOpenClosedMessage() {
            if(isOpen())
                  System.out.println(openMessage);
            else
                  System.out.println(closeMessage);
      }      
      
      Public String toString() {
            return "Store Owner is " + Owner + "Store Hours are " + openTime + "am to " +
                              closeTime + "pm";
      }
      
      
}





0
drewman75
Asked:
drewman75
  • 4
  • 3
1 Solution
 
Tommy BraasCommented:
    Public String toString() {

Should be:
     public String toString() {
0
 
hoomanvCommented:
Public String toString() {

public --> lowercase
0
 
hoomanvCommented:
orangehead911 :) you're too fast
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Tommy BraasCommented:
Java keywords are all lower case. Class names should be in camel case (http://en.wikipedia.org/wiki/CamelCase) , and start with an upper case letter. Method and variable names should be in camel case (http://en.wikipedia.org/wiki/CamelCase) , and start with a lower case letter.
0
 
Tommy BraasCommented:
;-)
0
 
hoomanvCommented:
could be helpful

Code Conventions for the Java
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
0
 
drewman75Author Commented:
Thank you all so much.  That did the trick.  orangehead911, since you were, first, I will award the points.  Thanks to everyone who responded.  More points to be had I am sure as I will probably have lots of questions as I venture through learning Java. Thanks again.
0
 
Tommy BraasCommented:
We're here to help!

;-D
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now