Cannot find symbol symbol  : constructor

I'm a java student, I've recently started constructors and inheritence, I've been pouring over my text book
all day and I've can't work out what I have done wrong in my code.
class TestComputer
{  public static void main (String [ ] args)
     Computer IBM = new Computer ("IBM",286);
      System.out.println(IBM);
public class Computer extends TestComputer{
          protected String processorModel;
                protected int clockSpeed;
    public Computer() {
         this.processorModel = processorModel;
         this.clockSpeed = clockSpeed;
    public String toString ()
          String result = "Processor Model: " + processorModel + "\n";
                  result += "Clock Speed: " + clockSpeed + "\n";
          return result;
}The error I am getting is cannot find symbol constructor Computer(java.lang.String,int)
and I can't for the life of me work out why.
Edited by: FallingLeaves on Sep 9, 2008 11:07 PM

Computer IBM = new Computer ("IBM",286);The error message tells you everything you need to know. The above line is calling a constructor with 2 parameters: String and int. Where in your class is the constructor that takes those 2 parameters?

Similar Messages

  • Cannot find the Symbol

    my problem is:cannot find symbol variable coefsAndDegs ; Line 54
    please help me
    import java.util.*;
    class Term {
         private int coefficient;
         private int degree;
         public Term(int coefficient, int degree) {
              this.coefficient = coefficient;
              this.degree = degree;
         public int getCoefficient() {
              return coefficient;
         public int getDegree() {
              return degree;
    public class Polynomial {
        private char polyVar;
        private ArrayList<Term> terms;
        public void Polynomial(char polyVar, int ... coefsAndDegs) {
             Scanner kb = new Scanner(System.in);
             String polies = kb.nextLine();
              polyVar = polies.charAt(0);
             if (polyVar < 'a' || polyVar > 'z') {
                  throw new IllegalArgumentException("Invalid polynomial variable.");
             } else {
                  this.polyVar = polyVar;
             // check that coefsAndDegs are provided in pairs..
             if (coefsAndDegs.length % 2 != 0) {
                  throw new IllegalArgumentException("Coefficients and Degrees must be provided in pairs.");
             } else {
                  terms = new ArrayList<Term>();
                  for (int i = 0; i < coefsAndDegs.length / 2; i++) {
                       Term term = new Term(coefsAndDegs[i * 2], coefsAndDegs[i * 2 + 1]);
                       terms.add(term);
        public void main(String[] args){
         Polynomial main = new Polynomial();
        Polynomial(polyVar, coefsAndDegs);          
    }

    bluez_exe wrote:
    my problem is:cannot find symbol variable coefsAndDegs ; Line 54And what line is that? These forums don't have line numbers, and most of us are waay too lazy to copy and paste your code into something that does.
    What do you expect this to do:
    public void main(String[] args){
         Polynomial main = new Polynomial();
         Polynomial(polyVar, coefsAndDegs);          
              }Or this:
    if (polyVar < ' || polyVar > 'z')

  • HT4437 cannot find airplay symbol in safari

    I just recently installed Apple Tv to my TV.  I am having trouble finding the airplay on my macbook pro in safari.  I can access my music and photos via my wifi connection but cannot find the airplay symbol on my laptop.

    Yeah it's annoying, any audio or video on iOS is available for AirPlay by default, but not on OS X.
    If you have a new computer, you may be able to mirror your entire Mac's display via AirPlay mirroring. Go to System Preferences, Displays, and see if AirPlay Mirroring is an option at the bottom of the window.
    The best way for the time being is to play this content from an iOS device, or find it through the Apple TV apps (if it's YouTube or Vimeo).
    Edit: You can AirPlay all your system audio by holding down Alt, pressing the volume icon in your menubar, and selecting Apple TV. This is for Mountain Lion only, and just sends all audio that would normally come from your speakers.

  • Cannot find file symbol not showing up

    Hi -
    I have just done a massive move and backup etc. Things are going fine - just learned that every time you "reorganized" itunes music the entire file structure changes so a real back up with something like SyncBack totally ***** but...
    The question is...
    I know that there are about 50 files that do not have the proper file association. Last night there were the little exclamation points next to the song so I could find and correct them. I closed itunes and turned the computer off for the night. And now this morning when I open up the computer and itunes I cannot tell which songs still need updating because the little exclamation points are gone. How do I get those symbols back??!! (And yes, there still are files to be corrected I test that this morning)
    Thank you anyone who can help me out with this - I hope to some day soon have a clean itunes library AND backup

    I don't think your picture has anything to do with Spotlight. My Applications folder shows up the exact same way. Mac OS X applications aren't usually a single item, they're "packages" with items and folders inside. To get folders and packages to show their size, you'll have to change the "View Options" from the View menu. Check the box on to "Calculate all sizes". I would probably change the dialog box to reflect the changes to "This window only". Otherwise the Finder will be re-calculating the size of everything in every window. That could slow things down a bit.
    -Doug

  • Cannot find symbol class ParseException

    I have this in my code how ever
    DateFormat formatter = new SimpleDateFormat("ddMMyyyy");
    dDateStamp = (Date)formatter.parse(dateStamp);
    When I pass in say
    dateStamp=safsadssad sa;
    I get an error which is fine.
    I can not seem to catch this error with try catch
    When I use the one below it says it cannot find the symbol
    When i use the Exception it still throws and error to jsp page
    cannot find symbol
    symbol : class ParseException
    }catch(ParseException e){   
    symbol : class ParseException
    }catch(ParseException e){   
    Any One know I csn trap this?
    Thanks in advance

    Well, it's in the j2se API. Not sure what to tell you...

  • Cannot Find Symbols: 'getDefaultInstance' 'MimeMessage' 'RecipientType' !!

    Hi all,
    I'm trying to send mail using Sun Java Studio Ceator 2 IDE
    using this code
        public String cmdSend_action() {
            //TODO: set the from, to addresses and the mail server
            String from = "******@yahoo.com"; // from address
            String to = "********@*******.com"; // to address
            String host = "*****.**.***.*****.com";
            // please note that if your mail server requires authentication,
            // this code may not work
            try
                // Get system properties
                Properties props = (Properties)System.getProperties().clone();
                // Setup mail server
                props.put("mail.smtp.host", host);
                // Get session
                Session session = Session.getDefaultInstance(props, null);
                // Define message
                MimeMessage message = new MimeMessage(session);
                message.setFrom(new InternetAddress(from));
                message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
                message.setSubject("Hello JavaMail");
                message.setText("Welcome to JavaMail");
                // Send message
                Transport.send(message);
            catch (java.io.IOException ex)
                // in the case of an exception, print a message to the output log
                log("ERROR SENDING EMAIL:"+ex);
                error("ERROR SENDING EMAIL: " + ex.getMessage());
            catch (Exception e)
                log("ERROR SENDING EMAIL:"+e);
                error("ERROR SENDING EMAIL: " + e.getMessage());
            return null;
        }but as seen in the below screen shot, the IDE cannot find some symbols
    http://i18.tinypic.com/4552ez8.gif
    although I've fixed imports & that's my imports
    import com.sun.rave.web.ui.appbase.AbstractPageBean;
    import com.sun.rave.web.ui.component.Body;
    import com.sun.rave.web.ui.component.Form;
    import com.sun.rave.web.ui.component.Head;
    import com.sun.rave.web.ui.component.Html;
    import com.sun.rave.web.ui.component.Link;
    import com.sun.rave.web.ui.component.Page;
    import javax.faces.FacesException;
    import com.sun.rave.web.ui.component.Label;
    import com.sun.rave.web.ui.component.TextArea;
    import com.sun.rave.web.ui.component.Button;
    import com.sun.rave.web.ui.component.MessageGroup;
    import javax.jms.Message;
    import javax.jms.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import java.util.Properties;
    import java.net.SocketPermission;I downloaded the latest version of javamail-1.4 & jaf-1.1
    and coppied the mail.jar & activation.jar to SunAppServer8\domains\creator\lib & SunAppServer8\lib directories
    but the problem remains!
    I followed these instructions http://java.sun.com/products/javamail/classpath-NT.html
    to set my CLASSPATH as shown in this screen shot:
    http://i17.tinypic.com/2vah1j4.gif
    but the problem remains!!
    I've also added these to the security policy file used by the application
    grant {
        // following two permissions allow
        // access to default config files
        permission java.io.FilePermission
              "...path/SunAppServer8/domains/creator/lib/mail.jar", "read";
        permission java.io.FilePermission
              "...path/SunAppServer8/domains/creator/lib/activation.jar", "read";
        // following to use SMTP
        permission java.net.SocketPermission
              "SMTPHOST:25", "connect,resolve";
        // following to use IMAP
        permission java.net.SocketPermission
              "IMAPHOST:143", "connect,resolve";
        // following to use POP3
        permission java.net.SocketPermission
              "POP3HOST:110", "connect,resolve";
        // following needed if System.getProperties() is used
        permission java.util.PropertyPermission
              "*", "read,write";
    };but also the problem remains!!!!!
    Please help me with this so annoying problem
    I'm stucked in it for weeks
    Thanks in advance.

    Thanks bshannon for trying to help,
    I've solved this issue by just adding this import
    import javax.mail.*;Best regards.

  • Constructor - cannot find symbol

    Hi all,
    Can anyone please help me with this code? I don't know what's wrong with it.
    class Superclass {
        public int j = 0;   
        public Superclass(String text){  //constructor
            j = 1;
    class Subclass extends Superclass {
        public Subclass(String text){  //constructor - error here: cannot find symbol       
            j = 2;       
        public static void main(String[] args){
            Subclass sub = new Subclass("");
            System.out.println(sub.j);
    }What's wrong with the subclass c'tor? What symbol is it missing?
    Thank you for your replies.

    I'm wondering, why do we need the c'tor from the superclass? Is it because it is not inherited? That's why we need to manually write it? NO. It is because you have not written a no argument constructor in your superclass and compiler is calling it when you actually creating a instance of subclass.
    If there are many other superclass c'tors with different types of arguments, do we have to explicitly write each one of them in the subclass c'tor? Is that correct?NO. You just need to call only one with the parameters that you actually need to pass to superclass.
    If you dont put the super(text); in subclass constructor then too it looks for the superclass constructor while creating a instance of subclass. But since if you are not calling a constructor with arguments[which in now done by super(text)] it will look for a default constructor in your superclass which is no argument constructor. & you dont have any no argument constructor in your Superclass.
    Try you code like this. It will work but in this case you are not passing text to your super class. If you want to pass text then you have to use super(text) in your subclass.
    class Superclass {
        public int j = 0; 
        public Superclass()
        public Superclass(String text){      
            j = 1;
        public Superclass(int count){
            count = 10;
    class Subclass extends Superclass {    
        public Subclass(String text){  
            //super(text);  // have to write this line
            j = 2;       
        public Subclass(int count){
            super(count); // have to write this line also
            count = 15;
        public static void main(String arg[]){
             Subclass  s = new Subclass("e");
    }I hope it helps.

  • Cannot find symbol:constructor

    here is my code...
    package org.tiling.didyoumean;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.BufferedReader;
    import org.apache.lucene.index.Term;
    import org.apache.lucene.queryParser.ParseException;
    import org.apache.lucene.search.Query;
    import org.apache.lucene.search.TermQuery;
    import org.apache.lucene.search.spell.SpellChecker;
    import org.apache.lucene.store.Directory;
    import org.apache.lucene.store.FSDirectory;
    import org.apache.commons.cli.ParseException;
    public class spell {
         public static void main(String args[]){
              System.out.println("hi");
         String spellIndex = "C://opt//lucene//didyoumean//indexes//spell";
         SpellChecker spellChecker = new SpellChecker(spellIndex);
         String[] similarWords = spellChecker.suggestSimilar("jva", 1);
         System.out.println(similarWords[0]);
    }and the error i am kept getting is
    C:\Documents and Settings\sumit-i\Desktop\didyoumean\didyoumean-1.0\src\java>javac org/tiling/didyoumean/spell.java
    org\tiling\didyoumean\spell.java:29: cannot find symbol
    symbol  : constructor SpellChecker(java.lang.String)
    location: class org.apache.lucene.search.spell.SpellChecker
            SpellChecker spellChecker = new SpellChecker(spellIndex);
                                        ^
    1 errorany ideas..plzz

    here is the Directory.java,....please help me if you can....actually i have a deadline to submit this..but i am not getting this...
    package org.apache.lucene.store;
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    *     http://www.apache.org/licenses/LICENSE-2.0
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    import java.io.IOException;
    /** A Directory is a flat list of files.  Files may be written once, when they
    * are created.  Once a file is created it may only be opened for read, or
    * deleted.  Random access is permitted both when reading and writing.
    * <p> Java's i/o APIs not used directly, but rather all i/o is
    * through this API.  This permits things such as: <ul>
    * <li> implementation of RAM-based indices;
    * <li> implementation indices stored in a database, via JDBC;
    * <li> implementation of an index as a single file;
    * </ul>
    * Directory locking is implemented by an instance of {@link
    * LockFactory}, and can be changed for each Directory
    * instance using {@link #setLockFactory}.
    * @author Doug Cutting
    public abstract class Directory {
      /** Holds the LockFactory instance (implements locking for
       * this Directory instance). */
      protected LockFactory lockFactory;
      /** Returns an array of strings, one for each file in the
       * directory.  This method may return null (for example for
       * {@link FSDirectory} if the underlying directory doesn't
       * exist in the filesystem or there are permissions
       * problems).*/
      public abstract String[] list()
           throws IOException;
      /** Returns true iff a file with the given name exists. */
      public abstract boolean fileExists(String name)
           throws IOException;
      /** Returns the time the named file was last modified. */
      public abstract long fileModified(String name)
           throws IOException;
      /** Set the modified time of an existing file to now. */
      public abstract void touchFile(String name)
           throws IOException;
      /** Removes an existing file in the directory. */
      public abstract void deleteFile(String name)
           throws IOException;
      /** Renames an existing file in the directory.
       * If a file already exists with the new name, then it is replaced.
       * This replacement is not guaranteed to be atomic.
       * @deprecated
      public abstract void renameFile(String from, String to)
           throws IOException;
      /** Returns the length of a file in the directory. */
      public abstract long fileLength(String name)
           throws IOException;
      /** Creates a new, empty file in the directory with the given name.
          Returns a stream writing this file. */
      public abstract IndexOutput createOutput(String name) throws IOException;
      /** Returns a stream reading an existing file. */
      public abstract IndexInput openInput(String name)
        throws IOException;
      /** Returns a stream reading an existing file, with the
       * specified read buffer size.  The particular Directory
       * implementation may ignore the buffer size.  Currently
       * the only Directory implementations that respect this
       * parameter are {@link FSDirectory} and {@link
       * org.apache.lucene.index.CompoundFileReader}.
      public IndexInput openInput(String name, int bufferSize) throws IOException {
        return openInput(name);
      /** Construct a {@link Lock}.
       * @param name the name of the lock file
      public Lock makeLock(String name) {
          return lockFactory.makeLock(name);
       * Attempt to clear (forcefully unlock and remove) the
       * specified lock.  Only call this at a time when you are
       * certain this lock is no longer in use.
       * @param name name of the lock to be cleared.
      public void clearLock(String name) throws IOException {
        if (lockFactory != null) {
          lockFactory.clearLock(name);
      /** Closes the store. */
      public abstract void close()
           throws IOException;
       * Set the LockFactory that this Directory instance should
       * use for its locking implementation.  Each * instance of
       * LockFactory should only be used for one directory (ie,
       * do not share a single instance across multiple
       * Directories).
       * @param lockFactory instance of {@link LockFactory}.
      public void setLockFactory(LockFactory lockFactory) {
          this.lockFactory = lockFactory;
          lockFactory.setLockPrefix(this.getLockID());
       * Get the LockFactory that this Directory instance is
       * using for its locking implementation.  Note that this
       * may be null for Directory implementations that provide
       * their own locking implementation.
      public LockFactory getLockFactory() {
          return this.lockFactory;
       * Return a string identifier that uniquely differentiates
       * this Directory instance from other Directory instances.
       * This ID should be the same if two Directory instances
       * (even in different JVMs and/or on different machines)
       * are considered "the same index".  This is how locking
       * "scopes" to the right index.
      public String getLockID() {
          return this.toString();
       * Copy contents of a directory src to a directory dest.
       * If a file in src already exists in dest then the
       * one in dest will be blindly overwritten.
       * @param src source directory
       * @param dest destination directory
       * @param closeDirSrc if <code>true</code>, call {@link #close()} method on source directory
       * @throws IOException
      public static void copy(Directory src, Directory dest, boolean closeDirSrc) throws IOException {
          final String[] files = src.list();
          if (files == null)
            throw new IOException("cannot read directory " + src + ": list() returned null");
          byte[] buf = new byte[BufferedIndexOutput.BUFFER_SIZE];
          for (int i = 0; i < files.length; i++) {
            IndexOutput os = null;
            IndexInput is = null;
            try {
              // create file in dest directory
              os = dest.createOutput(files);
    // read current file
    is = src.openInput(files[i]);
    // and copy to dest directory
    long len = is.length();
    long readCount = 0;
    while (readCount < len) {
    int toRead = readCount + BufferedIndexOutput.BUFFER_SIZE > len ? (int)(len - readCount) : BufferedIndexOutput.BUFFER_SIZE;
    is.readBytes(buf, 0, toRead);
    os.writeBytes(buf, toRead);
    readCount += toRead;
    } finally {
    // graceful cleanup
    try {
    if (os != null)
    os.close();
    } finally {
    if (is != null)
    is.close();
    if(closeDirSrc)
    src.close();
    please let me know....if you any idea about it..
    thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Please! WHY? Why does the main class cannot find symbol symbol : constructor Car(double) location: class Car?

    Why does the main class cannot find symbol symbol : constructor Car(double) location:
    class Car .. ??
    class Car
    { //variable declaration
    double milesStart; double milesEnd; double gallons;
    //constructors
    public Car(double start, double end, double gall)
    { milesStart = start; milesEnd = end; gallons = gall; }
    void fillUp(double milesE, double gall)
    { milesEnd = milesE; gallons = gall; }
    //methods
    double calculateMPG()
    { return (milesEnd - milesStart)/gallons; }
    boolean gashog() { if(calculateMPG()<15) { return true; } else { return false; } }
    boolean economycar() { if(calculateMPG()>30) { return true; } else { return false; } } }
    import java.util.*; class MilesPerGallon
    { public static void main(String[] args)
         double milesS, milesE, gallonsU;
         Scanner scan = new Scanner(System.in);
         System.out.println(\"New car odometer reading: 00000\");
          Car car = new Car(milesS); car.fillUp(milesE, gallonsU);
         System.out.println(\"New Miles: \" + milesE); milesE = scan.nextDouble();
         System.out.println(\"Gallons used: \" + gallonsU);
         gallonsU = scan.nextDouble();
         System.out.println( \"MPG: \" + car.calculateMPG() );
         if(car.gashog()==true) { System.out.println(\"Gas Hog!\");
          if(car.economycar()==true) { System.out.println(\"Economy Car!\");
         } System.out.println(\"\");
         milesS = milesS + milesE;
         System.out.println(\"Enter new miles\");
          milesE = scan.nextDouble();
         System.out.println(\"Enter gallons used: \");
          gallonsU = scan.nextDouble();
         car.fillUp(milesE, gallonsU);
         System.out.println(\"Initial miles: \" + milesS);
         System.out.println(\"New Miles: \" + milesE);
         System.out.println(\"Gallons used: \" + gallonsU);
         System.out.println( \"MPG: \" + car.calculateMPG() );
         System.out.println(\"\"); } }

    Why does the main class cannot find symbol symbol : constructor Car(double) location:
    class Car .. ??
    Please tell us which line of code you posted shows 'Car (double)'.
    The only constructor that I see is this one:
    Car(double start, double end, double gall)

  • Compiler error: "cannot find symbol" - constructor

    Dear all,
    I keep getting the compiler error "cannot find symbol" - constructor AWTEvent() for the following class. It's supposed to extend AWTEvent to give me my own event to be fired. What could be wrong?
    import java.awt.*;
    import java.awt.event.*;
    public class MyButtonEvent extends AWTEvent
         public MyButtonEvent()
    }Thanks a lot!
    N

    When you do this
    public MyButtonEvent()
    }you are implicitly calling the super class constructor with no parameters
    That is:
    AWTEvent();
    you can think of it as
    public MyButtonEvent()
         AWTEvent(); // <-- automatically generated for you
         //the rest of your stuff
    }the problem is that AWTEvent has no such constructor, so you need to explicitly put another constructor in your constructor as the first statement. This other constructor has to be one that exists in AWTEvent.

  • Error:Cannot find symbol Symbol Constructor

    Anyone who can help..
    I need to write a program that has two camera's and define a camera class so it prints out the total of the camera's at the end. I keep getting different errors it seems like I fix one and another one pops up, but this one has me confused. It is the following program:
    public class Program2
              public static void main (String [] args)
                   Camera home = new Camera(10);
                   Camera work = new Camera(30);
                   home.takePic();
                   home.takePic();
                   home.takePic();
                   home.erasePic();
                   home.printNum();
                   home.takePic();
                   home.takePic();
                   home.eraseAll();
                   home.printNum();
                   work.takePic();
                   work.takePic();
                   work.printNum();
         class Camera
         public Camera ();
              private int pictures;
                   pictures = 0;
              public void takePic()
                   pictures++;
              public void erasePic()
                   pictures--;
              public void eraseAll()
                   pictures = 0;
              public void printNum()
                   System.out.println("This camera has " + pictures +
                        " on it.");
    and I get this error:
    Program2.java:5: cannot find symbol
    symbol : constructor Camera(int)
    location: class Camera
                   Camera home = new Camera(10);
                   ^
    Program2.java:6: cannot find symbol
    symbol : constructor Camera(int)
    location: class Camera
                   Camera work = new Camera(30);
                   ^
    Anyone know what is going on? I am so confused any help would be absolutely wonderful!
    Thanks,
    K

    Program2.java:5: cannot find symbol
    symbol : constructor Camera(int)
    location: class Camera
    Camera home = new Camera(10);
    It says, when it tries to execute the statement
    Camera home = new Camera(10);
    It could not find the Camera(int) constructor, since you have provided such constructor in your program.
    Just add the following constructor in your program, and it should work.
    public Camera (int pictures);
    this.pictures = pictures;
    Nice to meet you.

  • [Greenfoot] "cannot find symbol - constructor Plotter"?

    I am attempting to make a sinusoid plotter as part of my math class. Using Greenfoot, I have created a class Plotter, which is supposed to accept amplitude, frequency, vertical displacement, and phase displacement and then plot the resulting sinusoid. Everything works fine, except when I try to compile the program I get an error message "cannot find symbol - constructor Plotter(float,float,float,float)" when I compile the World object which creates the Plotter object. My call in the World object's constructor:
    GraphWorld()
    // Create the field, which is 800x450 pixels.
    super(800, 450, 1);
    // These will eventually be set by a prompt to the user.
    float amp = 1;
    float freq = 1;
    float vd = 0;
    float pd = 0;
    addObject(new Plotter(amp,freq,vd,pd), 0, 225);
    }I am currently using a workaround by changing the code directly within the Plotter class, but I would like to find the source of the problem.

    Grey_Ghost wrote:
    It should.That's what the compiler thinks too.
    Here is the constructor as it is defined in class Plotter:
    public void Plotter(float Amplitude, float Frequency, float VertDisp, float PhaseDisp)
    amplitude = Amplitude;
    frequency = Frequency;
    vertDisp = VertDisp;
    phaseDisp = PhaseDisp;
    Except that's not a constructor. Constructors don't have return values.

  • Cannot find symbol error - Constructor

    Hi Folks,
    i am getting the following errors when the code is compiled. Please help! The code is as below. This code is for the laptop configuration. I have 2 classes, computer.java and Wclass.java with the WIn.java(main class)
    Also, how do i read the input from the radiobutton in the action performed
    WClass.java:13: cannot find symbol
    symbol : constructor Computer()
    location: class Computer
    Computer computer = new Computer();
    ^
    WClass.java:181: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,java.lang.String)
    Out.append("Computer Configuration for %s\n", computer.getName()
    ^
    WClass.java:182: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("Processor:\t\t\t \n", computer.getProcessor());
    ^
    WClass.java:183: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("HardDisk: \t\t\t \n", computer.getHarddisk());
    ^
    WClass.java:184: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("RAM: \t\t\t \n", computer.getRam());
    ^
    WClass.java:185: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("ProcessorSpeed:\t\t \n", computer.getProcessorSpeed(
    ^
    WClass.java:186: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("Printer: \t\t\t \n", computer.getPrinter());
    ^
    WClass.java:187: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("Inbuilt Wireless LAN: \t\t\n", computer.getWireless(
    ^
    WClass.java:188: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("Floppy(External):\t\t \n", computer.getFloppy());
    ^
    WClass.java:189: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("DVD Writer:\t\t\t \n", computer.getDVD());
    ^
    WClass.java:190: append(java.lang.String) in javax.swing.JTextArea cannot be applied to (java.lang.String,float)
    Out.append("CD Writer :\t\t\t \n", computer.getCdw());
    ^
    WClass.java:191: cannot find symbol
    symbol : method getTotal()
    location: class Computer
    Out.append("Total \t\t\t \n", computer.getTotal());
    ^
    12 errors
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    public class Computer
         private String name;
         private float Processor_cost;
         private float total_cost;
         private float harddrive_cost;
         private float ram_cost;
         private float psspeed_cost;
         private float printer_cost;
         private float wireless_cost;
         private float floppy_cost;
         private float dvd_cost;
         private float cdwriter_cost;
         float pc[] = {1000f, 700f, 650f, 1200f};
         float hd[] = {0, 100f, 150f};
         float ps[] = {0, 100f, 125f};
         float ram[] = {0, 60f};
         float aa[] = {50f, 110f};
         float drive[] = {110f, 220f, 20};
         double T = 0.0;
    public Computer(String Cname, int pcost, float tcost, int hcost, float rcost,
    int pscost, float prcost, float wcost, float fcost, float dvdcost, float cdrwcost)
         name = Cname;
         Processor_cost = pc[pcost];
         total_cost = tcost;
         harddrive_cost = hd[hcost];
         ram_cost = rcost;
         psspeed_cost = ps[pscost];
         printer_cost = prcost;
         wireless_cost = wcost;     
         floppy_cost = fcost;
         dvd_cost = dvdcost;
         cdwriter_cost = cdrwcost;
    public void setName(String Cname)
         name = Cname;
    public String getName()
         return name;
    public void setProcessor(int pcost)
         Processor_cost = pc[pcost];
    public float getProcessor()
         return Processor_cost;
    public void setHarddisk(int hcost)
         harddrive_cost = hd[hcost];
    public float getHarddisk()
         return harddrive_cost;
    public void setRam(int rcost)
         ram_cost = rcost;
    public float getRam()
         return ram_cost;
    public void setProcessorSpeed(int pscost)
         psspeed_cost = ps[pscost];
    public float getProcessorSpeed()
         return psspeed_cost;
    public void setPrinter(float prcost)
         printer_cost = prcost;
    public float getPrinter()
         return printer_cost;
    public void setWireless(float wcost)
         wireless_cost = wcost;
    public float getWireless()
         return wireless_cost;
    public void setFloppy(float fcost)
         floppy_cost = fcost;
    public float getFloppy()
         return floppy_cost;
    public void setDVD(float dvdcost)
         dvd_cost = dvdcost;
    public float getDVD()
         return dvd_cost;
    public void setCdw(float cdrwcost)
         cdwriter_cost = cdrwcost;
    public float getCdw()
         return cdwriter_cost;
    //public String show()
    //     String out;
         //return out.format();
    public double Total()
         T = getProcessor() + getHarddisk() + getRam() + getProcessorSpeed() + getPrinter() + getWireless() + getFloppy() + getDVD() + getCdw();
         return T;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class WClass extends JFrame implements ActionListener
         Computer computer = new Computer();
         private JPanel P1;
         private JPanel P2;
         private JButton submit;
         private JButton clear;
         private JTextArea Out;
         private JLabel name;
         private JTextField Custname;
         private JComboBox processor;
         private JComboBox harddrive;
         private JRadioButton ram1;
         private JRadioButton ram2;
         private JRadioButton ram3;
         private JPanel radiopanel;
         private ButtonGroup radiogroup;
         private JComboBox processorsd;
         private JLabel L1;
         private JCheckBox printer;
         private JCheckBox lan;
         private JLabel L2;
         private JCheckBox fpy;
         private JCheckBox dvd;
         private JCheckBox cdrw;
         private JLabel L3;
         private JLabel L4;
         private JLabel L5;
         private JLabel L6;
         private JLabel L7;
         private JLabel L8;
         private JLabel L9;
         private Container c;
         int row;
         float prncost = 50f;
         float wlan = 110f;
         float fppy = 110f;
         float dvdw = 220f;
         float cdw = 20f;
         public WClass()
              super("Laptop Configuration");
              P1 = new JPanel();
              P1.setLayout(new GridLayout(10,2,5,10));
              P2 = new JPanel(new BorderLayout());
              name = new JLabel("Customer Name");
              P1.add(name);
              Custname = new JTextField(10);
              Custname.addActionListener(this);
              P1.add(Custname);
              L3 = new JLabel("Processor");
              P1.add(L3);
              String p[] = {"Pentium 4", "Celeron", "AMD", "Intel Centrino"};
              processor = new JComboBox(p);
              processor.setMaximumRowCount(3);
              P1.add(processor);
              L4 = new JLabel("Hard Disk");
              P1.add(L4);
              String h[] = {"30 GB", "40 GB", "60 GB"};
              harddrive = new JComboBox(h);
              harddrive.setMaximumRowCount(2);
              P1.add(harddrive);
              L5 = new JLabel("RAM");
              P1.add(L5);
              radiopanel = new JPanel();
              radiopanel.setLayout(new GridLayout(1,2));
              ram1 = new JRadioButton("256 MB", true);
              ram2 = new JRadioButton("512 MB", false);
              radiopanel.add(ram1);
              radiopanel.add(ram2);
              radiogroup = new ButtonGroup();
              radiogroup.add(ram1);
              radiogroup.add(ram2);
              P1.add(radiopanel);
              L6 = new JLabel("Processor Speed");
              P1.add(L6);
              String ps[] = {"1.8 GHz", "2.2 GHz", "2.8 GHz"};
              processorsd = new JComboBox(ps);
              processorsd.setMaximumRowCount(2);
              P1.add(processorsd);
              L1 = new JLabel("Additional Accessories");
              P1.add(L1);
              printer = new JCheckBox("Ink Jet Printer");
              lan = new JCheckBox("Inbuilt Wireless LAN");
              P1.add(printer);
              L7 = new JLabel("");
              P1.add(L7);
              P1.add(lan);
              L2 = new JLabel("Drives");
              P1.add(L2);
              fpy = new JCheckBox("Floppy(External)");
              dvd = new JCheckBox("DVD Writer");
              cdrw = new JCheckBox("CD Writer");
              P1.add(fpy);
              L8 = new JLabel("");
              P1.add(L8);
              P1.add(dvd);
              L9 = new JLabel("");
              P1.add(L9);
              P1.add(cdrw);
              c = getContentPane();
              add(P1, BorderLayout.NORTH);
              submit = new JButton("Submit");
              clear = new JButton("Clear");
              Out = new JTextArea(10,5);
              P2.add(submit, BorderLayout.WEST);
              P2.add(clear, BorderLayout.EAST);
              P2.add(Out,BorderLayout.CENTER);
              add(P2, BorderLayout.SOUTH);
         public void actionPerformed(ActionEvent event)
              if(event.getSource() == submit)
              computer.setName(name.getText());
              computer.setProcessor(processor.getSelectedIndex());
              computer.setHarddisk(harddrive.getSelectedIndex());
              //computer.setRam(radiogroup.getAccessibleContext());
              computer.setProcessorSpeed(processorsd.getSelectedIndex());
              if(printer.isSelected())
                   computer.setPrinter(prncost);
              if(lan.isSelected())
                   computer.setWireless(wlan);
              if(fpy.isSelected())
                   computer.setFloppy(fppy);
              if(dvd.isSelected())
                   computer.setDVD(dvdw);
              if(cdrw.isSelected())
                   computer.setCdw(cdw);
              Out.append("Computer Configuration for %s\n", computer.getName());
              Out.append("Processor:\t\t\t \n", computer.getProcessor());
              Out.append("HardDisk: \t\t\t \n", computer.getHarddisk());
              Out.append("RAM: \t\t\t \n", computer.getRam());
              Out.append("ProcessorSpeed:\t\t \n", computer.getProcessorSpeed());
              Out.append("Printer: \t\t\t \n", computer.getPrinter());
              Out.append("Inbuilt Wireless LAN: \t\t\n", computer.getWireless());
              Out.append("Floppy(External):\t\t \n", computer.getFloppy());
              Out.append("DVD Writer:\t\t\t \n", computer.getDVD());
              Out.append("CD Writer :\t\t\t \n", computer.getCdw());
              Out.append("Total \t\t\t \n", computer.getTotal());
              if(event.getSource() == clear)
                   Custname.setText("");
                   Out.setText("");
                   ram1 = new JRadioButton("256 MB", true);
                   c.setLayout(new GridLayout(10,2,5,10));
    import javax.swing.JFrame;
    public class Win
         public static void main(String args[])
              WClass window = new WClass();
              window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
              window.setSize( 500,550);
              window.setVisible( true);
    }

    When you make a class, the compiler often gives you an empty constructor. The Computer class for example would have the following constructor.
    public Computer(){ }This means you can write code, as you did in the third program like the following.
    Computer c = new Computer();However if you write your own constructor such as:
    public Computer(String Cname, int pcost, float tcost, int hcost, float rcost,
    int pscost, float prcost, float wcost, float fcost, float dvdcost, float cdrwcost)Then an empty constructor is not supplied. So you must write your own if you want one or you must use the one that you created.
    You can create as many constructors as you like, so long as they all take different arguments

  • Cannot find symbol while referring to an overloaded constructor

    Hi, I've a VERY strange problem. It's an hour I'm trying to work this out without any luck....
    here is my code
         public DueDPanel(int limite, int valore, int incremento) throws NumberOutOfBoundException
              this.limite=limite;
              setValore(valore);
              upBy=incremento;
         public DueDPanel(int limite, int valore) throws NumberOutOfBoundException
              { DueDPanel(limite,valore,1); }
         public DueDPanel(int limite) throws NumberOutOfBoundException
              { DueDPanel(limite,0,1); }
         public DueDPanel() throws NumberOutOfBoundException
              { DueDPanel(99,0,1); }I get a c-time error
    .\DueDPanel.java:25: cannot find symbol
    symbol : method DueDPanel(int,int,int)
    location: class DueDPanel
    { DueDPanel(limite,valore
    ^
    .\DueDPanel.java:28: cannot find symbol
    symbol : method DueDPanel(int,int,int)
    location: class DueDPanel
    { DueDPanel(limite,0,1);
    ^
    .\DueDPanel.java:31: cannot find symbol
    symbol : method DueDPanel(int,int,int)
    location: class DueDPanel
    { DueDPanel(99,0,1); }
    How could it be? why in the world it cannot find my int,int,int method?
    I'm damn sure this is an easy problem, but..... thankyou sooooo much!!

    Ok, a superior-class developer friend of mine found a solution.
    I simply replaced the method indetifier with this(....).
    public DueDPanel() throws NumberOutOfBoundException
              { this(99,0,1); }Could someone please explain why this didn't work as I expeced?

  • Xerces cannot find symbol problem

    In my program I get an Xml from an exist database and want to place it in the hard drive.
    I have made the xerces imports I need:
    import org.apache.xerces.domx.XGrammarWriter.OutputFormat;
    import org.apache.xml.serialize.XMLSerializer;I have the jar on my classpath.and the code I am getting trouble with is:
    OutputFormat format = new OutputFormat(doc2);
                        format.setIndenting(true);
                        XMLSerializer serializer = new XMLSerializer(new FileOutputStream(new File("C:\\Configuration\\XmlCopy.xml")), format);I get the following errors
    C:\.....\Wizard1.java:2946: cannot find symbol
    symbol  : constructor OutputFormat(org.w3c.dom.Document)
    location: class org.apache.xerces.domx.XGrammarWriter.OutputFormat
                        OutputFormat format = new OutputFormat(doc2);
    C:\.....\Wizard1.java:2947: cannot find symbol
    symbol  : method setIndenting(boolean)
    location: class org.apache.xerces.domx.XGrammarWriter.OutputFormat
                        format.setIndenting(true);
    C:\....\Wizard1.java:2948: cannot find symbol
    symbol  : constructor XMLSerializer(java.io.FileOutputStream,org.apache.xerces.domx.XGrammarWriter.OutputFormat)
    location: class org.apache.xml.serialize.XMLSerializer
                        XMLSerializer serializer = new XMLSerializer(new FileOutputStream(new File("C:\\Configuration\\XmlCopy.xml")), format);Any ideas about what I'm doing wrong?

    StruL wrote:
    Instead of GrammarWriter.OutPutFormat.class it says GrammarWriter$OutPutFormat.class.
    relevant or plain stupid?
    Neither really,
    GrammarWriter.OutPutFormat is the name of the class,
    GrammarWriter$OutPutFormat.class is the file into which the class is stored.
    As to you problem the error messages you posted referred to
    C:\.....\Wizard1.java:2946: cannot find symbol
    symbol  : constructor OutputFormat(org.w3c.dom.Document)
    location: class org.apache.xerces.domx.XGrammarWriter.OutputFormatnote dom*x* and XGrammarWriter ,
    this is not the same as dom.GrammarWriter...

Maybe you are looking for