public class Z3_2_Tester{
public static void main(String[] args){
char[] tablica = {'S','O','M','E','T','E','X','T'};
Z3_2 z = new Z3_2();
z.Z3_2(tablica);
}
}
class Z3_2{
static char toUpperCase(char t)
{
//tablica = t;
System.out.println(t);
}
}
You've got three mistakes at the moment - one is not an error, it's just a really bad idea. The other ones are what you're running into at the moment.
Firstly, you've got a static method, but you're calling it as if it were an instance method. Don't do that - it means your code doesn't do what it looks like it's doing. You should call a static method just by the class name:
Z3_2.toUpperCase(...);
The second problem is that your method is called toUpperCase
, but you're trying to call it as if it were called Z3_2
... that's the name of the class, not the method.
The third problem is that your method has a parameter type of char
, but you're trying to pass in a char[]
. You either need to change the parameter type, or call it with a single char
at a time, e.g.
for (char c : tablica) {
Z3_2.toUpperCase(c);
}
Additionally:
toUpperCase
method return something, given that it has a return type of char
toUpperCase
in main
Z3_2
is meaningless. Names are important - choose them carefully.See more on this question at Stackoverflow