java 如何在Android中使用goto语句

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5087607/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 09:20:31  来源:igfitidea点击:

How to use the goto statement in Android

javaandroid

提问by sam_k

How can I use gotoin Android?

我如何goto在 Android 中使用?

采纳答案by maid450

Tha language used in Androidis Java, and there isn't any gotoby itself in Java.

Android 中使用的语言是Java,而gotoJava 本身没有任何语言。

You can use a labeled breakor other alternatives as described in an answer to Stack Overflow question Alternative to a goto statement in Java, but these constructs should be avoided as long as possible, as they produce really ugly and hard-to-maintain code.

您可以使用标记break或其他替代方法,如Stack Overflow 问题替代 Java 中的 goto 语句的答案中所述,但应尽可能避免使用这些构造,因为它们会产生非常丑陋且难以维护的代码。

Just figure out how to design your code correctly, and you will never need gotoand such stuff ;-)

只要弄清楚如何正确设计你的代码,你就永远不需要goto这些东西了 ;-)

回答by bschaffer13

If you are using the AndroidSDKin Java you cannot use a goto statement. Java does not provide a goto statement in its grammar.

如果您在 Java中使用Android SDK,则不能使用 goto 语句。Java 在其语法中没有提供 goto 语句。