The Artima Developer Community
Sponsored Link

Java Answers Forum
cannot resolve symbol

1 reply on 1 page. Most recent reply: Jun 28, 2002 4:51 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
william mccann

Posts: 1
Nickname: wfm
Registered: Jun, 2002

cannot resolve symbol Posted: Jun 28, 2002 8:55 AM
Reply to this message Reply
Advertisement
when I try to compile a java program Test.java I get the following error:

[parsing started Test.java]
[parsing completed 253ms]
[loading /usr/j2se/jre/lib/rt.jar(java/lang/Object.class)]
[loading /usr/j2se/jre/lib/rt.jar(java/lang/String.class)]
[checking Test]
[loading ./PsidCustomerUsage.class]
[loading ./CustomerUsage.class]
Test.java:20: cannot resolve symbol
symbol : constructor PsidCustomerUsage (java.lang.String,double,double,double,
double,double,double,double,double,doub le,double,double,double,java.lang.String,
java.lang.String)
location: class PsidCustomerUsage
new PsidCustomerUsage(phn,1.00,2.00,3.00,4.00,5.00,6.00,7.00,8.00,9.00,10.00,
^
[to tal 4759ms]
1 error

The program Test.java:
 
import java.io.*;
import java.util.*;
import java.text.*;
import java.net.*;
import java.sql.*;
import java.lang.*;
 
 
public class Test {
 
   public static void main(String args[]) {
 
    String phn = "1234567890";
    String desc = "S";
    String psidno = "01";
    PsidCustomerUsage aPsidCustomerUsage;
 
    aPsidCustomerUsage=
new PsidCustomerUsage(phn,1.00,2.00,3.00,4.00,5.00,6.00,7.00,8.00,9.00,10.00,
11.00,12.00,desc,psidno);
 }
}


The program PsidCustomerUsage.java

import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
 
 
public class PsidCustomerUsage extends CustomerUsage
  {
    public Double psidPkCalls;
    public Double psidPkMins;
    public Double psidOpkCalls;
    public Double psidOPkMins;
    public String psidDescription;
    public String psidNo;
 
// constructor method
    public PsidCustomerUsage(String newPhone, Double newMthFee, Double newNrc,
                          Double newPkMins, Double newOpkMins, Double newAir,
                          Double newRoamChg, Double newRoamMin, Double newNoMo,
                          Double newPsidPkCalls, Double newPsidPkMins,
                          Double newPsidOPkCalls, Double newPsidOPkMins,
                          String newpsidDescription, String newpsidNo)
    {
     super(newPhone, newMthFee, newNrc, newPkMins, newOpkMins, newAir,
           newRoamChg, newRoamMin, newNoMo);
     psidPkCalls = newPsidPkCalls;
     psidPkMins = newPsidPkMins;
     psidOpkCalls = newPsidOPkCalls;
     psidOPkMins = newPsidOPkMins;
     psidDescription = newpsidDescription;
     psidNo = newpsidNo;
 
    }
 
   public Double getPsidPkCalls ()
    { return psidPkCalls; }
 
   public Double getPsidPkMins ()
    { return psidPkMins; }
 
   public Double getPsidOPkCalls ()
    { return psidOpkCalls; }
 
   public Double getPsidOPkMins ()
    { return psidOPkMins; }
 
   public String getPsidDescription ()
    { return psidDescription; }
 
   public String getPsidNo ()
    { return psidNo; }
 
  }


The program CustomerUsage.java:

public abstract class CustomerUsage
 {
  // CustomerUsage attribute definitions...
   public String phone;
   public Double mth_fee;
   public Double nrc;
   public Double pk_mins;
   public Double opk_mins;
   public Double air_chgs;
   public Double roam_chgs;
   public Double roam_mins;
   public Double no_months;
 
  // Constructor method to create an instance
   public CustomerUsage(String newPhone, Double newMthFee, Double newNrc,
                        Double newPkMins, Double newOpkMins, Double newAir,
                        Double newRoamChg, Double newRoamMin, Double newNoMo)
    {
       phone = newPhone;
       mth_fee = newMthFee;
       nrc = newNrc;
       pk_mins = newPkMins;
       opk_mins = newOpkMins;
       air_chgs = newAir;
       roam_chgs = newRoamChg;
       roam_mins = newRoamMin;
       no_months = newNoMo;
    }
 
  // Mutator methods...
   public void setPhone (String newPhone)
    { phone = newPhone; }
 
   public void setMthFee (Double newMthFee)
    { mth_fee = newMthFee; }
 
  // Accessor Methods...
   public String getPhone ()
    { return phone;}
 
   public Double getMthFee ()
    { return mth_fee;}
 
   public Double getNrc ()
    { return nrc;}
 
   public Double getPkMins ()
    { return pk_mins; }
 
   public Double getOpkMins ()
    { return opk_mins; }
 
   public Double getAir ()
    { return air_chgs; }
 
   public Double getRoamChg ()
    { return roam_chgs; }
 
   public Double getRoamMin ()
    { return roam_mins; }
 
   public Double getNoMo ()
    { return no_months; }
 
 
 }// end CustomerUsage.java


Both PsidCustomerUsage.java and CustomerUsage.java compiled successfully and both reside (class files) in the same directory as Test.java.

Any suggestions?


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: cannot resolve symbol Posted: Jun 28, 2002 4:51 PM
Reply to this message Reply
Despite the error message, maybe this is because you have not initialized the variable, so try this:

PsidCustomerUsage aPsidCustomerUsage = new PsidCustomerUsage(phn, 1.00, 2.00,
3.00, 4.00, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00, 11.00, 12.00, desc, psidno );

Why is there a "doub le" in the error output? (Maybe it was at a line-wrap on the output?)

Check that you don't have another copy of this thing elsewhere in your classpath (you may have changed to a new working directory, or something).

From an API design standpoint, I would avoid having a constructor that takes 15 arguments. One of the worst things about the Microsoft Windows API is the plethora of functions that take 10+ parameters -- this is an invitation for confusion and mismatch errors, as well as being a major pain to work with. If you have so many parameters, it is probably a good indication that some refactoring is in order.

Flat View: This topic has 1 reply on 1 page
Topic: reading pixel value using mouse click event Previous Topic   Next Topic Topic: Why static this abstract factory?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use