用绳子switch语句中的Andr​​oid参数绳子、语句、参数、switch

2023-09-07 04:43:55 作者:唯为伊人诉惆怅

我想用一个switch语句中的Java 1.7这也让开关(someString)。但是,如果我改变了Java编译器1.7项目的休息,我要么回到1.5或使用 Android的工具 - >修复工程

I would like to use a switch statement as in Java 1.7 which also allows switch(someString). However if I change the java compiler to 1.7 the project breaks and I either have to go back to 1.5 or use android tools-> fix project.

有没有办法使用开关字符串在Android开发?

Is there any way to use switch with Strings in android development?

推荐答案

修改

就个人而言,我没有试过,但根据的Andr​​oid系统要求页面,这是不支持的。尽管如此,这并不意味着它是行不通的,只是你不可能从谷歌/ Android的主题得到太多/任何帮助。

Personally, I have not tried, but according to the Android System Requirements page, it is unsupported. That said, it does not mean that it wouldn't work, just that you are unlikely to receive much/any help on the subject from Google/Android.

JDK 5或JDK 6(JRE是不够)

JDK 5 or JDK 6 (JRE alone is not sufficient)

在一个潜在的积极的,(有@Emil H和他的评论的帮助下找到)我发现这些信息位在线:

On a potentially positive note, (found with the help of @Emil H and his comment) I have found these bit of information online:

从的Dalvik维基百科上:

程序通常用Java编写的一种方言,并编译成字节code。然后,他们是从Java虚拟机兼容的.class文件转换成Dalvik的兼容.dex(Dalvik的可执行文件)的文件...

Programs are commonly written in a dialect of Java and compiled to bytecode. Then they are converted from Java Virtual Machine-compatible .class files to Dalvik-compatible .dex (Dalvik Executable) files...

如果字节code不会从6的版本改为7(不包括添加 invokedynamic 通过@大卫·施瓦茨,提到其中开关语句不应该使用),那么它应该工作...

If the bytecode doesn't change from version 6 to 7 (excluding the added invokedynamic mentioned by @David Schwartz, which switch statements should not be using.), then it should work...

 
精彩推荐
图片推荐