I've been programming for years using .NET and I'm taking the plunge into Java with some simple starter programs.
I'm having a bit of trouble though...
When I create my start-up class with public void main, the compiler won't let me instantiate any of the classes I've written?
The error I'm getting is "non-static variable _processor cannot be referenced from a static context" where _processor is the object I'm trying to instantiate from the Processor class that I wrote.
The program will compile and run just fine when I change Processor to a static class, but I don't want to have to make all of my classes static.
Any way around this?
Thanks in advance!
Here's everything I've written. It won't compile in the current state:
class Lab
{
public static void main(String[] args)
{
Processor proc = new Processor();
proc.Go();
}
private class Processor
{
private Random _rand = new Random();
public void Processor() {}
public void Go()
{
}
}
}
_processor, but that doesn't occur in the code you've shown.