Java Android 声明一个变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6537538/
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
Android Declare a Variable
提问by Jeff Thomas
I was wondering if there is an easy way to declare a variable in android programming. I am still teaching myself however I haven't been able to find the answer to this question. I would like to do something like:
我想知道是否有一种简单的方法可以在 android 编程中声明变量。我仍在自学,但是我一直无法找到这个问题的答案。我想做类似的事情:
var1 = 'variable1';
var2 = 'variable2';
So that it can be called later in the code by its Variable.
以便稍后在代码中通过其变量调用它。
Thank you in advance.
先感谢您。
采纳答案by omermuhammed
I suggest learning Java fundamentals first. Declaring a variable is fundamental to Java programming language (and indeed many programming languages), its not just Android specific.
我建议先学习Java基础知识。声明变量是 Java 编程语言(以及许多编程语言)的基础,而不仅仅是 Android 特定的。
You can learn Java fundamentals here.
您可以在此处学习 Java 基础知识。
Good Luck in your learning
祝你学习顺利
回答by Leonard Brünings
What about
关于什么
private static final String VAR = "string constant variable";
String var1 = "string instance variable1";
Android is basically Java so simple look for java references.
Android 基本上是 Java,所以简单查找 java 引用。
回答by Anil M H
int a=10;
String b="kick";
char c;