Bluej Error Cannot Find Symbol
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn
Bluej Error Cannot Find Symbol - Variable
more about Stack Overflow the company Business Learn more about hiring developers or error cannot find symbol javac posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community
Error Cannot Find Symbol Class
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Java: constructor with one parameter; Error - Cannot find symbol error cannot find symbol maven - variable up vote 1 down vote favorite I'm in Java programming (I'm on my first year at uni). I've got an assessment where I need to create 3 classes. In one of the classes I need to have a constructor with a parameter of String type. It needs to allow me to create a new object (pack of crisps) in which I am supposed to state the error cannot find symbol class builder flavour of it. Whenever I try to create the object I get the textbox where I can type in the flavour of crisps but when I press ok I get the error (e.g. ) Cannot find symbol - variable bbq. I had a similar example before which took int type and it worked fine. When I compare my code with other - working examples - I really can't find what I am doing wrong. I would appreciate if someone could advise. public class PackOfCrisps { private String flavour; private int numOfCrisps; private boolean open; /** * Constructor for a single pack of crisps. */ public PackOfCrisps(String newFlavour) { flavour = newFlavour; numOfCrisps = 10; open = true; } /** * Return whether the packet is empty. */ public boolean isEmpty() { if (numOfCrisps == 0) { return true; } else return false; } /** * Return whether the packet is closed. */ public boolean isClosed() { return open; } /** * Change the boolean value of 'open' variable. */ public void open() { open = !open; } /** * Return the flavour of the packet of crisps. */ public String getFlavour() { return flavour; } /** * Decrease the number of crisps
Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Programming Languages Java
Error Cannot Find Symbol Method Findviewbyid(int)
Help BlueJ compiler error - cannot find symbol - variable
Error Cannot Find Symbol In Java
1 this Post To Linkedin Subscribe to this Thread Subscribe to This Thread March 24th, 2010,06:34 PM #1 No Profile Picture ben.w.barnes View Profile View Forum http://stackoverflow.com/questions/12875816/java-constructor-with-one-parameter-error-cannot-find-symbol-variable Posts Registered User Devshed Newbie (0 - 499 posts) Join Date Mar 2010 Posts 3 Rep Power 0 BlueJ compiler error - cannot find symbol - variable
3 Replies - 7166 Views - Last Post: 19 January 2009 - 01:40 PM Rate Topic: #1 h2o pete New D.I.C Head Reputation: 0 Posts: 5 Joined: 19-January 09 Cannot find symbol error Posted 19 January 2009 - 01:26 PM Bit stuck on this now http://www.dreamincode.net/forums/topic/81675-cannot-find-symbol-error/ lol. The question I've been set is: Add two accessor methods to the class - getAuthor https://answers.yahoo.com/question/index?qid=20100929214558AATNo8n and getTitle - that return the author and title fields as their respective results. Test your class by creating some instances and calling the methods. Every time I try to create a new book I get a cannot find symbol error. e.g. If I try to make a book with "john" as the author and "beingjohn" as the title I get this: Error: cannot error cannot find symbol - variable john It's probably something really stupid that I'm not seeing haha. I haven't been doing this long at all so I'm still not too confident with programming. I'm using BlueJ software by the way. I've got this so far: /** * A class that maintains information on a book. * This might form part of a larger application such * as a library system, for instance. * * @author (Peter Moncrieff.) * @version (17th January 2009.) */ error cannot find class Book { private String author; private String title; /** * Set the author and title fields when this object * is constructed. */ public Book(String bookAuthor, String bookTitle) { author = bookAuthor; title = bookTitle; } /** * Accesses the author */ public String getbookAuthor() { return author; } /** * Accesses the title */ public String getbookTitle() { return title; } } Thanks. This post has been edited by h2o pete: 19 January 2009 - 01:27 PM Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: Cannot find symbol error #2 Locke Sarcasm Extraordinaire! Reputation: 550 Posts: 5,624 Joined: 20-March 08 Re: Cannot find symbol error Posted 19 January 2009 - 01:32 PM Are you calling the constructor like this? Book book = new Book(john, beingJohn); // or like this...? Book book = new Book("John", "Being John"); The 2nd one is what you're looking for I believe. Strings are always enclosed in quotes, unless they are variables...like this next one. String john = "John"; String beingJohn = "Being John"; Book book = new Book(john, beingJohn); That one works equally well. Was This Post Helpful? 1 Back to top MultiQuote Quote + Reply #3 h2o pete New D.I.C Head Reputation: 0 Posts: 5 Joined: 19-January 09 Re: Cannot find symbol error Posted 19 January 2009 - 01:39 PM Locke37, on 19 Jan, 2009 - 12:32 PM, said:Are you calling the construct
Help Suggestions Send Feedback Answers Home All Categories Arts & Humanities Beauty & Style Business & Finance Cars & Transportation Computers & Internet Consumer Electronics Dining Out Education & Reference Entertainment & Music Environment Family & Relationships Food & Drink Games & Recreation Health Home & Garden Local Businesses News & Events Pets Politics & Government Pregnancy & Parenting Science & Mathematics Social Science Society & Culture Sports Travel Yahoo Products International Argentina Australia Brazil Canada France Germany India Indonesia Italy Malaysia Mexico New Zealand Philippines Quebec Singapore Taiwan Hong Kong Spain Thailand UK & Ireland Vietnam Espanol About About Answers Community Guidelines Leaderboard Knowledge Partners Points & Levels Blog Safety Tips Computers & Internet Programming & Design Next Bluej - Cannot find symbol - variable _____? Okay, So I've compiled the code, and it works just fine, but when I try to run my promotionalPrint method and i enter patron1 for the parameter, it says that it "cannot find symbol - variable patron1" Now i've tried with quotes, but that's just a string and i don't want that, entering... show more Okay, So I've compiled the code, and it works just fine, but when I try to run my promotionalPrint method and i enter patron1 for the parameter, it says that it "cannot find symbol - variable patron1" Now i've tried with quotes, but that's just a string and i don't want that, entering patron1 should work just fine because it just inputs patron1 in the second method where it calls to promotionalPrint. When i run the next method, printAllPatrons, which calls to promotionalPrint(patron1) it works just fine. Here's most of the code. public class BookClubReport { private String clubName; private ClubPatron patron1; private ClubPatron patron2; private ClubPatron patron3; /** * Constructor for objects of class BookClubReport */ public BookClubReport(String clubName) { this.clubName = clubName; patron1 = new ClubPatron("John Doe", "The Virginian"); patron2 = new ClubPatron("Jane Doe", "Deal Souls"); patron3 = new ClubPatron("Jeff Gannon", "Candide"); patron1.payDues(); patron3.payDues(); patron3.newBook("Moby Dick"); } //VV This is the method that I believe has the issue VV /** * Method to print out Patron as before, but with a PROMOTIONAL if they have never paid dues. */ public void promotionalPrint(ClubPatron patronWho) { if(patronWho.duesPaid() == true) { System.out.println("--------------------... patronWho.printPatron(); System.out.println("--------------------... } el