4th Nov 2018, 8:52 PM
Strovosky
Strovosky - avatar
7 Answers
+ 1
Forget declaring String name1, name2, ...; and after initialize Try to declare like this String name1 = "name1"; String name2 = "name2";
4th Nov 2018, 9:11 PM
Anya
Anya - avatar
+ 1
Oh. a committed a mistake yeah you can do what you said. The problem was when you declared outside of method the method can't see the variables because it's outside scope. So you need to pass to method or declared as global or declare inside. I was thinking was some weird sintax problem. But it's not.
4th Nov 2018, 10:36 PM
Anya
Anya - avatar
0
It worked! But why? Isn't it just the same declaring them and the initialize them?
4th Nov 2018, 9:47 PM
Strovosky
Strovosky - avatar
0
And sorry for asking but just how much java experience do you have?
4th Nov 2018, 9:48 PM
Strovosky
Strovosky - avatar
0
It also worked initializing them inside the method but I don't get why.
4th Nov 2018, 9:51 PM
Strovosky
Strovosky - avatar
0
Strovosky not my strongest language but i always use in university
4th Nov 2018, 10:39 PM
Anya
Anya - avatar