Henry Wong wrote:
You are not allowed to declare a method within another method.
Henry
Bear Bibeault wrote:
(P.S. When posting errors, copy and paste them verbatim.)
Stefan Evans wrote:Ok, what sort of errors do you get when you don't have it nested?
How should this program be executed? The main method is meant to be a starting point for the rest of your application, but you seem to have some Android Activity stuff happening as well, so it might not apply here.
Bear Bibeault wrote:
Bear Bibeault wrote:
(P.S. When posting errors, copy and paste them verbatim.)
Kevin D Brown wrote:With is setup "public static void main(String[] args)" I get these errors
this.. Error Cannot use this in a static context
setContentView(tv).. Error: Cannot make a static reference ti the non-static method setContentView(View) from the type Activity
Stefan Evans wrote:
Step 3: Take the code that is currently in your main method, and use it in the getMessage() method to get the text you want .
This is what the code should have looked like:-I am not saying anything about compiler errors or anything like that, but formatting errors are serious too. Because you hadn't indented the code correctly, you could not see what was happening, nor where methods start and finish. That is why you indent code. Can you get VS to do the indentation automatically?Kevin D Brown wrote:. . .
Non descriptive variable names are error-prone too. I have in mind: e, i, g (i don't see a reason to declare "i" outside for loop). Don't use "if (randomNumbers.size() <= 10)", instead, use "if (randomNumbers.size() <= g)" <<< but that g should say something more than g only.Campbell Ritchie wrote:formatting errors are serious too
Alaric Mustoe wrote:I noticed something when going through your code correct me if i am wrong but when you define the first method have you tried to place an end bracket to separate it and main this will not disconnect the two like a double end bracket but should fix the error if it is a illegal expression error.
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|