Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2004

Tip: Looking for answers? Try searching our database.

Java passing info?

Thread view: 
Randy Tingley - 02 Apr 2004 01:28 GMT
I have my program coded but I am throwing 5 errors.
I am sort of lost ... being a novice :)
The error is: symbol: class str    ???

Any comments would be helpful ... Thank you!

*************program below*********************
import TerminalIO.KeyboardReader;

public class LibraryInterface {

  public static void main (String[] args){

     // Instantiate the Patrons & Books and the keyboard

     Patron patron1 = new Patron();

     Patron patron2 = new Patron();

                       Patron patron3 = new Patron();

     KeyboardReader reader = new KeyboardReader();

     String name;

     str book;

     // Input the first patron's data

     name = reader.readLine("Enter the first patron's name: ");

     patron1.setName(name);

     for (int i = 1; i <= 3; i++){

        book = reader.readLine("Enter the book's title: ");

        student1.setbook(i, book);

     }

     // Input the second student's data

     name = reader.readLine("Enter the second patron's name: ");

     patron2.setName(name);

     for (int i = 1; i <= 3; i++){

        book = reader.readLine("Enter the book's title: ");

        patron2.setbook(i, book);

     }

                       // Input the third student's data

     name = reader.readLine("Enter the third patron's name: ");

     patron3.setName(name);

     for (int i = 1; i <= 3; i++){

        book = reader.readLine("Enter the book's title: ");

        patron3.setbook(i, book);

     }

     // Output the three patrons information

     System.out.println(patron1);

     System.out.println(patron2);

                       System.out.println(patron3);

  } // end method

} //end class

import TerminalIO.KeyboardReader;

public class LibraryInterface {

  public static void main (String[] args){

     // Instantiate the Patrons & Books and the keyboard

     Patron patron1 = new Patron();

     Patron patron2 = new Patron();

                       Patron patron3 = new Patron();

     KeyboardReader reader = new KeyboardReader();

     String name;

     str book;

     // Input the first patron's data

     name = reader.readLine("Enter the first patron's name: ");

     patron1.setName(name);

     for (int i = 1; i <= 3; i++){

        book = reader.readLine("Enter the book's title: ");

        student1.setbook(i, book);

     }

     // Input the second student's data

     name = reader.readLine("Enter the second patron's name: ");

     patron2.setName(name);

     for (int i = 1; i <= 3; i++){

        book = reader.readLine("Enter the book's title: ");

        patron2.setbook(i, book);

     }

                       // Input the third student's data

     name = reader.readLine("Enter the third patron's name: ");

     patron3.setName(name);

     for (int i = 1; i <= 3; i++){

        book = reader.readLine("Enter the book's title: ");

        patron3.setbook(i, book);

     }

     // Output the three patrons information

     System.out.println(patron1);

     System.out.println(patron2);

                       System.out.println(patron3);

  } // end method

} //end class

public class Book {

           //instance varibles

           private String author, title;

           //construction method

           public Book()

           {

                       author = " ";

                       title = " ";

           }

           //another constructor method - same name

           public Book(String author, String title)

           {

                       author = author;

                       title = title;

           }

           public String author()

           {

                       return(author);

           }

           public String title()

           {

                       return(title);

           }

           public String toString()

           {

                       return("Title: " + title + "\n" + "Author:" +
author);

           }

}
Mark Haase - 02 Apr 2004 01:59 GMT
>       str book;

at a glance, what is this? "str" is not a built-in java type...

|\/|  /|  |2  |<
mehaase(at)sas(dot)upenn(dot)edu
Randy Tingley - 02 Apr 2004 02:05 GMT
The first class "LibraryInterface", I am trying to
code for user input.  The rest of the programs compile.
I keep throwing an error in the public class LibraryInterface.

> >       str book;
>
> at a glance, what is this? "str" is not a built-in java type...
>
> |\/|  /|  |2  |<
> mehaase(at)sas(dot)upenn(dot)edu
Bjorn Abelli - 02 Apr 2004 11:33 GMT
"Randy Tingley" wrote...

> I have my program coded but I am throwing 5 errors.
> I am sort of lost ... being a novice :)
> The error is: symbol: class str    ???

I believe the error tells it all.

In your code you have the following line:

>       str book;

This is interpreted by the compiler as that you want a variable "book" of
*type* "str", but it can't find any definition of type "str".

My guess is that you really want to use a string instead...

     string book;

// Bjorn A
Chris Smith - 02 Apr 2004 15:07 GMT
> My guess is that you really want to use a string instead...
>
>       string book;

Except that "string" isn't a commonly defined class either (and it would
be very poor form for anyone else to define such a class).  If this
direction is correct, what's really wanted is probably:

       String book;

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Randy Tingley - 02 Apr 2004 22:06 GMT
> > My guess is that you really want to use a string instead...
> >
[quoted text clipped - 5 lines]
>
>         String book;

Thanks! I will take a look at that.
Bjorn Abelli - 03 Apr 2004 12:19 GMT
> > > My guess is that you really want to use a string instead...
> > >
[quoted text clipped - 6 lines]
> >
> >         String book;

Of course!

That's what I meant, but it seems I've been coding too much in C# lately...
;-)

// Bjorn A


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.