如果用户传递一个基本类型参数println(),那么场景后面到底发生了什么?例如
int i =1;
System.out.println("My Int"+i);
//and in
System.out.println(i)
Run Code Online (Sandbox Code Playgroud)
它是如何打印"My Int 1"和"1",即使它需要一个String对象?
更新..
我认为是AutoBoxing发挥作用.这也是真的吗?
这甚至是可能的,很少有人认为它可能,我在这里看到它也链接 ..但是当我亲自尝试它给我编译时错误..
我的意思是,
Class A{
private final String data;
public A(){
data = "new string";
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢..
所以我正在观看教程,我正在尝试理解这种语法
Thread thread = new Thread()
{
//if i declare variables here i get errors
public void run()
{
// ....define variables in function
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码是如何工作的?我认为在创建线程对象时,它定义了向函数"列表"添加或"附加"函数?因此可以稍后调用thread.run()或thread.start().我不确定我在猜猜.有人可以启发我.从我在run函数中看到的教程中他做到了这一点
//the same run that is in the Thread class
public void run()
{
int timer = 0 ;
while(timer < 5000)
{
sleep(100) ;
timer+=100;
}
}
Run Code Online (Sandbox Code Playgroud)
睡觉做什么?我用谷歌搜索它但找不到任何好的东西.在继续循环之前,它是否基本上停止当前应用程序100毫秒?睡眠被称为50次?我在数学上很糟糕大声笑..但如果是这样,那么上面的代码是等同于
public void run()
{
int timer = 0 ;
while(timer < 50)
{
sleep(100) ;
timer++;
}
}
Run Code Online (Sandbox Code Playgroud)
但是我知道最简单的方法就是说睡眠(5000);
显然,我是一个菜鸟.所以我会感激任何解释......彻底的更好的谢谢.对不起,没有想法如何使用代码标签..
尽管我在java中做了一些编码,但我仍然觉得很难理解这个基本概念.当我读完一本书时,我遇到了这一行,
main( )必须声明为public,因为它必须在程序启动时由其类之外的代码调用.
作者在课堂之外说代码是什么意思?
public int getChildrenCount(int groupPosition) {
if(children == null){
new SalesRequest().execute(); // runs in other thread which
// initialises children with some value.
while(children == null){
// I'm doin this to avoid null pointer Exception.
// So it comes out of the loop only when childern
// gets initialised.
}
}
return children.length;
}
Run Code Online (Sandbox Code Playgroud)
但我对我处理这个问题的方式并不满意.有一个更好的方法吗?
我有一个表格行,当它聚焦时我尝试了许多改变颜色的东西,但是在聚焦时它永远不会改变颜色.有没有办法做到这一点?我试过这个也改变了点击的颜色,但只有当它集中注意力时:
r.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent arg1) {
if(arg0.isFocused())
{
arg0.setBackgroundColor(Color.BLUE);
//arg0.isFocused();
}
return false;
}});
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中收到此错误.我只是想知道这个错误exaclty意味着什么.如果你举一个简单的例子来解释,那将是非常好的
An error has occurred. See error log for more details.
java.lang.NullPointerException (Probably The best way of describing an exception)..
Run Code Online (Sandbox Code Playgroud)
当我尝试打开我的.java文件时出现上述错误...它只是没有出现在我的编辑器中......我被困在这里..我使用eclipse juno ...
这就是我做的..
而已..
我正在尝试通过提供基于用户名和密码的登录以及用于用户身份验证的 google oAuth 来使用 Spring Boot 实现基本登录页面。
想知道 spring 是否允许使用同一个应用程序来完成此操作。
任何帮助将非常感激。
我不知道这是一个问题还是它的方式,但我需要一个2位小数的值.我可以编写一个函数来将它舍入2位小数,但是有一个解决方案,其中clojure本身在添加时处理它.我的意思是改变数据类型或其他东西.
谢谢.
java ×6
android ×4
add ×1
clojure ×1
decimal ×1
eclipse ×1
eclipse-juno ×1
final ×1
google-oauth ×1
oauth ×1
spring-boot ×1
sqlite ×1
syntax ×1