non-static method... cannot be referenced from a static contex
I've read a ton on this topic but none seem to fit my needs. I continue to get the "cannot be referenced from a static context" error. I understand that it is because I am referencing a method that is not static in another class, with a static main method of another class but from my understanding by using these statements:
Tank tank1 = new Tank(tlengthIn, twidthIn, wdepthIn);
Pipe pipe1 = new Pipe(pipelengthIn,pipeoutdIn, pipeindIn);
Pipe pipe2 = new Pipe(pipe2lengthIn, pipe2outdIn, pipe2indIn);
It should work. Any suggestions or corrections are welcome! Here is the rest:
if (Tank.setpipe(pipe1))
{
System.out.println("Pipe # 1 fits in the tank.");
Tank.setpipe(pipe1) = null;
System.out.println("The water depth is now: " + Tank.getwaterdepth());
}
else
{
System.out.println("Pipe # 1 does not fit in the tank.");
System.out.println("The water depth remains at: " + Tank.getwaterdepth());
}
if (Tank.setpipe(pipe2))
{
System.out.println("Pipe # 2 fits in the tank");
System.out.println("The water depth is now: " + Tank.getwaterdepth());
Tank.setpipe(pipe2) = null;
}
else
{
System.out.println("Pipe #2 does not fit in the tank.");
System.out.println("The water depth remains at: " + Tank.getwaterdepth());
Message was edited by:
starslight

