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 mock java.time.LocalDate.now()
getting hibernate exception when i upload image
Need of an object in synchronised block
How to use MongoDB in JAVA without writing code snippets multiple times for nested jsons?
Spring security check error
How to display text on JFrame or JPanel?
Hibernate gives me an error because an object references an unsaved transient instance - but I want it to remain unsaved in the DB
How to use a compareTo function in java
CF10 web service error after updating to Java 8 v 60
How to navigate back to my app instead of going down the backstack?
How to crawl mobile website java?
Unable to set value in byte format to upload file to database
Java ResultSet empty but actually it shouldn't be
BufferOverflowException while converting int to byte
Intersection of rectangles in java
have an android error with a game

Categories

HOME
ms-access
cakephp
variables
azure-data-factory
mockito
platform-builder
gps
fsm
umd
serverspec
uber-api
bs4
facebook-php-sdk
adobe-analytics
rascal
circular-dependency
iron-router
serverless-framework
progressive-web-apps
tostring
normalizr
swingx
custom-wordpress-pages
arabic
mmap
devops
jndi
xpages-ssjs
nhapi
rst2pdf
ejabberd-module
instant-messaging
bosh
xquery-3.0
create-table
column-family
pim
textmate
xmlreader
plsql-psp
restlet
hot-module-replacement
multilingual
lumberjack
nxlog
estimote
password-encryption
flashair
gpx
skeleton-css-boilerplate
angular-resource
long-polling
dds
hendrix
typescript1.8
dropbox-php
tactic
jspdf-autotable
deadbolt-2
sts-springsourcetoolsuite
trash
pcf
gstreamer-0.10
wso2cloud
thredds
sframe
microbenchmark
cisco-ios
dereference
notify
clicktag
dd
starcluster
expected-exception
java.nio.file
soundtouch
ftps
ril
eventlistener
robotics-studio
kyotocabinet
regsvr32
amazon-appstore
gnustep
qt-jambi
subgurim-maps
infobox
google-friend-connect
dentrix
xsdobjectgen
premature-optimization

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App