java


Cannot find class in another file [duplicate]


This question already has an answer here:
What does a “Cannot find symbol” compilation error mean?
8 answers
I've looked at answers other users have asked for similar question and still can't figure out why I'm getting can't find symbol errors for two classes I've created.
My dir looks like this
StacksAndQueuesProblems/threestacks
inside the threestacks directory, I have the following .java files:
FullStackException.java
fixedMultiStack.java
From the StacksAndQueuesProblems directory I tried to execute javac threestacks/*.java
however I get the following error:
threestacks/fixedMultiStack.java:20: error: cannot find symbol
throw FullStackException("ERR: That stack is full!");
^
FullStackException.java
package threestacks;
public class FullStackException extends Exception {
public FullStackException(String message) {
super(message);
}
}
fixedMultiStack.java
package threestacks;
class fixedMultiStack {
private int numberOfStacks = 3;
private int stackCapacity;
private int[] values;
private int[] sizes;
public fixedMultiStack(int stackCapacity) {
this.stackCapacity = stackCapacity;
values = new int[stackCapacity * numberOfStacks]; // Holds all 3 stacks
sizes = new int[numberOfStacks+1]; // Holds the number of items in each stack
}
/* push value onto stack */
public void push(int stackNum, int value) throws FullStackException {
/* check if we have space on the stack for the element */
if (isFull(stackNum)) {
throw FullStackException("ERR: That stack is full!");
}
/* increment stack pointer and then insert the value */
sizes[stackNum]++; // Increment the number of items for that stack
values[indexOfTop(stackNum)] = value; // Insert the value into the array
}
/* Pop item from the stack */
public void pop(int stackNum) {
if (isEmpty(stackNum)) {
throw new EmptyStackException();
}
/* Retreive the value and decrement the stack pointer */
int topIndex = indexOfTop(stackNum);
int value = values[topIndex]; //Get top
values[topIndex] = 0; // Clear
sizes[stackNum]--; // Decrement the size of the stack
}
/* Return top element */
public int peek(int stackNum) {
if (isEmpty(stackNum)) {
throw new EmptyStackException();
}
int topIndex = indexOfTop(stackNum);
int value = values[topIndex];
return value;
}
/* Return if stack is empty */
public boolean isEmpty(int stackNum) {
return sizes[stackNum] == 0;
}
/* Return if stack is full */
public boolean isFull(int stackNum) {
return sizes[stackNum] == stackCapacity;
}
/* Returns index of top of stack */
public int indexOfTop(int stackNum) {
return ((stackNum -1) * stackCapacity + sizes[stackNum] - 1);
}
}
There is a compilation error in the file fixedMultiStack.java. It should be
throw new FullStackException("ERR: That stack is full!");

Related Links

how can i modify main method to get input and output from the comandline?
Drools list iteration issue
Using a homemade library of classes as functions in other class files
Android java module “jar” file dependency issue
Split Array without delimiters?
How to display a 10-by-10square matrix with JavaFX?
Java program how to read multiple Doubles in one line?
passing a variable string through a textfield for a digital clock in java fxml
Most straightforward way of running old java applets [duplicate]
Error running .jar on a Mac
Disabling TLS1.1, TLS1.2, SSLv2Hello and SSLv3 on a java 7 application
How do you access an array in python from Java
Java/Jsoup - HTML element's ID changes with each refesh
autowire give null calling in webservice
Using AES symmetric key for generating tokens
Beginner Java - classes compiler error

Categories

HOME
cakephp
pandas
xamarin
arduino-uno
log4j
image
reflection
tinymce
relay
sd-card
cplex
amortized-analysis
graphql
rubygems
electronics
pivotal-cloud-foundry
autotools
remote-access
visual-studio-2005
ups
decimal
designer
caml
clojurescript
seaborn
graphlab
jsdoc
angular-ui
graphicsmagick
jndi
lcd
rundeck
pepper
bootstrap-duallistbox
fifo
strncpy
libssl
srcset
librato
gsoap
flink-streaming
pdb
mapdb
catalog
jmonkeyengine
wixsharp
hilbert-curve
hp-ux
gzipstream
ncalc
jvm-languages
galleria
jquery-validate
boost-multi-index
hls.js
gabor-filter
sqlclient
magma
media-player
cudafy.net
flow-control
mcafee
webdriverjs
yt-project
probability-density
qpid
fputcsv
superstack
master-slave
bluegiga
php-parse-error
tform
python-3.2
mutation-observers
dukescript
operation
generic-programming
sortedlist
jsapi
fscommand
rdtsc
fluentautomation
xceed-datagrid
fmod
page-layout
ccss
file-locking
qt-faststart
seed
tinn-r
itmstransporter
google-email-migration
gdata-api
buildr
work-stealing
genshi
coercion
tomcat-valve
xmemcached
horizontal-accordion
invite
table-footer
file-comparison
celltable
locate
html-input
preference
asp.net-profiles
substrings
exchange-server-2003
backcolor
privilege
phonon
anti-piracy
noscript
sector
procedural-music
gacutil
signal-handling
ajax-forms

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App