0

I'am writing android application with couple activities in eclipse. I have one object in MainActivity and I want it to be visible in all others activities, so i've made it:

public static cPlayer player = new cPlayer(); 

and when I do:

switch (MainActivity.player.getName())

I have error:

Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted

And it want to change JRE to 1.7. So i do it. But after that i have another error:

Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.

But after that, the previous problem returns.

Please help.

1 Answers1

0

In java switch statement didn't support String.

Up through Java 6 you could only evaluate primitive variable such as floats, longs, boolean, Integers and so on...

That changed with the Java Version 7.

However that is not the default SDK that comes with android.

If you want to use these features you'll need to use the Java 7 Developers Kit from Oracle.

meda
  • 45,103
  • 14
  • 92
  • 122