public class Hello {
public static final Hello h = new Hello();
static int i = 5;
int j = i;
private void print() {
System.out.println(i+" , "+j);
}
public static void main(String[] args) {
h.print();
}
}
Run Code Online (Sandbox Code Playgroud)
这个代码输出是5,0.如果原因是静态加载在类中的第一个并且我被初始化并且j不是.但是如果我从i中删除静态也
public class Hello {
public static final Hello h = new Hello();
int i = 5;
int j = i;
private void print() {
System.out.println(i+" , "+j);
}
public static void main(String[] args) {
h.print();
}
}
Run Code Online (Sandbox Code Playgroud)
现在为什么输出是5,5.然后当i和j初始化时.请解释原因.
public static void main(String[] args){
one();
two();
three();
}
public static void one() {
String s1 = "hill5";
String s2 = "hill" + 5;
System.out.println(s1==s2);
}
public static void two() {
String s1 = "hill5";
int i =5;
String s2 = "hill" + i;
System.out.println(s1==s2);
}
public static void three() {
String s1 = "hill5";
String s2 = "hill" + s1.length();
System.out.println(s1==s2);
}
Run Code Online (Sandbox Code Playgroud)
输出是
true
false
false
Run Code Online (Sandbox Code Playgroud)
字符串文字使用实习过程,然后为什么two()而且three()是假的.我可以理解three()但是two()不清楚.但是需要对这两种情况进行适当的解释.
有人可以解释正确的理由吗?
我在android中的地图项目中工作.它包含10000x10000分辨率的更大图像.使用此图像Bitmap给出OutOfMemoryError.所以我想平铺并滚动这个图像.当我滚动图像时,只有可见屏幕必须有瓷砖,其他隐形瓷砖必须回收.我花了很多时间但没有找到任何东西.
任何帮助将不胜感激.为我提供更好的解决方案或想法
class Parent
{
private void method1()
{
System.out.println("Parent's method1()");
}
public void method2()
{
System.out.println("Parent's method2()");
method1();
}
}
class Child extends Parent
{
public void method1()
{
System.out.println("Child's method1()");
}
public static void main(String args[])
{
Child p = new Child();
p.method2();
}
}
Run Code Online (Sandbox Code Playgroud)
ans是
Parent's method2()
Parent's method1()
Run Code Online (Sandbox Code Playgroud)
如果我正在创建Child类的对象,那么为什么输出是父类方法?即使method1在父级中也是私有的.它动摇了我所有的遗产概念.
我想使用adb shell将韩语或其他非英语文本发送到Android设备.选择的输入键盘语言是韩语,但它始终使用adb input keyevent命令以英语显示字符.如果我从设备输入它可以工作.
同样的事情是在模拟器中工作但不在真实设备上.
我正在使用这种布局使图像和文本在中心.但它不工作.我只是使用android:layout_centerHorizontal ="true".为什么它不工作我不明白.有人可以帮忙解决这个问题吗?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:background="@drawable/image_tutorial1" />
<TextView
android:textSize="14dp"
android:id="@+id/title"
android:layout_below="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/info4"
android:textColor="#000000"
android:textStyle="bold" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) byte b = 5;
int n = 33;
b<<n
b>>n
Run Code Online (Sandbox Code Playgroud)
我知道如何计算:如果这是左移,那么我们需要将数字乘以 2 的 n 次方,对于右移,我们必须将数字除以 2 的 n 次方。
如果n是小数我可以计算。有人可以解释一下如果 n 很大(比如这里是 33)如何手动计算它,或者还有其他方法吗?