[5230] in java-interest
Re: stack
daemon@ATHENA.MIT.EDU (COLLINS-LEE)
Fri Feb 2 18:53:38 1996
Date: Fri, 02 Feb 96 16:03:29 CST
From: "COLLINS-LEE" <collinsl@norcmail.uchicago.edu>
To: java-interest@java.sun.com, ochs@ee.vill.edu (Paul Ochs)
Paul,
It took a while to reply but here it is. Hope this helps.
class CurrentDirectory extends Applet
{
Stack theStack;
CurrentDirectory()
{
theStack = new Stack();
}
public String currentDirectory()
{
if (theStack.empty())
return null;
// peek() returns what is at the TOP of the stack
Object o = theStack.peek();
if ( o instanceof String )
{
// we know this assignment works because o IS an
instance of String - IT IS A STRING
String str = o;
return str;
}
else // if its NOT a String then its not a Directory so
return null
{
return null;
}
};
public void pushDirectory(String theDir)
{
theStack.push(theDir);
}
public String popDirectory()
{
// check to see if anything is on the stack
if (theStack.isEmpty())
return null;
// Pop the thing off the stack
Object o = theStack.pop();
// see if its a String
if ( o instanceof String )
{
// we know this assignment works because o IS an
instance of String - IT IS A STRING
String str = o;
return str;
}
else // if its NOT a String then its not a Directory so
return null
{
return null;
}
}
}
______________________________ Reply Separator _________________________________
Subject: stack
Author: ochs@ee.vill.edu (Paul Ochs) at INTERNET
Date: 1/28/96 11:27 AM
hello,
Can anyone send some info about java.util.stack?
Demonstrations, sample code, doc, etc... anything.
thanks
paul
//----------------------------------------------------------------------
class LeeCollins extends JavaDeveloper implements IllustriousJavaCode
{
public LeeCollins()
{
MailAddress ma =
new MailAddress("collinsl@norcmail.uchicago.edu");
}
}
//----------------------------------------------------------------------
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com