Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can you input data from a file & place it outside the main method?

807598Oct 24 2006 — edited Oct 24 2006
When I input integers into my program from an outside text file, I can easily use those numbers when assigned to variables inside the main method, but when I try to use them outiside the main method, the program will not recognize them.

I am bringing the integers into the main method, assigning them to variables, and then trying to use them here:
public class Maze
{
	//These should be imported from a text file.txt
	(This is where I am trying to assign the integers input from the file)
	final static int mazeWidth = msg, mazeHeight=15, enterRow=14, enterCol=17, exitRow=0, exitCol=33,
	north=0, east=1, south=2, west=3;

	//#ABE
    static protected char maze[] = new char[ mazeWidth * mazeHeight ];

	//Main Method
	static public void main(String[] args)
	{
		(THIS is where the integers are being brought in from the text file)
	}
}
Thanks for your help.

Message was edited by:
louy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2006
Added on Oct 24 2006
20 comments
252 views