• Post Reply Bookmark Topic Watch Topic
  • New Topic

input for multiple methods  RSS feed

 
nate dizzle
Greenhorn
Posts: 1
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry if this is wrong forum please move.

Hi everyone im new here, and new to java. I just started my java 1 course this summer and we are moving fast. For this lab we are calling multiple methods. So what im trying to do now is store the variables in the different methods.

here is what sample output would look like:
what is your city? san antonio

what is your stat? tx

enter the population of san antonio: 1382951

enter the population of tx: 26059203

POPULATION STATISTICS

city:san antonio
stat: tx
city population: 1,382,951
state population: 26,059,203
city to state population: 5.31%



and this is my error
1 error found:
File: C:\Users\SJB Sony\Desktop\JAVA\BonczkedNSLE51.java [line: 22]
Error: Syntax error on token "cityName", VariableDeclaratorId expected after this token
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The problem is because you aren't allowed to declare a private static variable inside a method body. In your case you've already declared this variable in the class body so you can use it without the "private static" part.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh and well done for posting a properly constructed question with all the required details and for using code tags on your first post
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:Oh and well done for posting a properly constructed question with all the required details and for using code tags on your first post
Exactly - that deserves a cow!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!