This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Illegal start of type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Illegal start of type" Watch "Illegal start of type" New topic
Author

Illegal start of type

Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
I wanted to add a new method initializeArray and it is supposed to make an array of 13 by 6 of '*' Now I'm getting a illegal start of type on the method right underneath.
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 74
Sorry ignore the above code, the problem I'm having is that instead of getting an array of * i'm getting an array of 00.
I know it must be out of the scope but i'm not sure where.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's a lot of code to look at to figure out one specific issue--it might make more sense to show just the code relevant to your specific issue (and header comments never need to be posted; they only obfuscate real issues...) Make it easy for us! :)
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
Sorry i'm having a problem with the initializeArray method not giving out * like I want to and printMatrix method is not seeing initializeArray
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Where do you call initializeArray?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And if everything is static, why do you still pass seatNumber around?
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
I probably didn't call initializeArray I don't know how to call methods I guess. I don't know why I pass seatNumber around, should I change all the seatNumber to matrix? Sorry I'm pretty new to java.
Vineet Kakati
Greenhorn

Joined: May 03, 2010
Posts: 21
I tried to compile your your code and there were no compilation errors.
If there is some logical error please elaborate on it.

Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
It does compile nicely but It isn't working the way I want it to. I want it to print out an array of asteriks * so it will look something like this

and so on but i'm gettin something that looks like this

printMatrix doesn't recognize initializeArray and I think
its because I didn't call a method or something
or it may have to do with the scope?
Vineet Kakati
Greenhorn

Joined: May 03, 2010
Posts: 21
You are not giving a call to function initializeArray() anywhere;
call function initializeArray() in main before do while loop;



Also I noticed that your code works only once i.e after allotting 1 seat the program terminates.
I suppose you want to allot more than 1 seat;

I suggest taking user input to decide whether to break 'do while' loop or not.
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
I suppose I should also add that I am trying to get this initializeArray method to work so that after the program takes all the input from the user I would like to have a loop that lets the user enter another seat selection by restarting the program or reset the seating chart by calling the method initializeArray. Once I figure out how to call a method that is.
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
That sounds like an awesome idea but i've been searching google for most of the night to figure out a way to call a method. I'm new to Java could you give me an example of a way to call this method or a nudge in the right direction for what the code should look like to call a method?

WOW that worked very well and it was sooo simple I feel bad for having a headache so easily
now I only need to look at a way to make this thing loop the way I want it to... or how the user wants it to.
Thank you
Vineet Kakati
Greenhorn

Joined: May 03, 2010
Posts: 21
simply write


immediately after


That should do the trick.
Vineet Kakati
Greenhorn

Joined: May 03, 2010
Posts: 21
To make program loop as per user input simply change your outermost 'do while' loop.

1:Put the 3 function calls printMatrix ,chooseSeat, printMatrix(1,13) inside 'do while' loop;

2:Then ask user if he wants to allot another seat.

Refer the code snippet below
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
That worked out great! But lets say that I wanted to either end the program, restart it, or reset the seating chart, in order to reset the seating chart would I have to call initializeArray from the main method?
Thank you
 
 
subject: Illegal start of type
 
Similar Threads
do {} while statement illegal start of type
Write a method that can be called, that will initialize the seating plan.
print invalid selction not working
Logic problem or invoke method problem
Booking bus tickets with each member only max of 4 seats