小编Blo*_*rot的帖子

在java中使用关键字"this"

我试图了解java关键字this实际上做了什么.我一直在阅读Sun的文档,但我仍然对this实际操作有些模糊.

java keyword

19
推荐指数
4
解决办法
6万
查看次数

字符串相等与位置相等

String s1 = "BloodParrot is the man";  
String s2 = "BloodParrot is the man";  
String s3 = new String("BloodParrot is the man");  

System.out.println(s1.equals(s2));
System.out.println(s1 == s2);
System.out.println(s1 == s3);
System.out.println(s1.equals(s3));
Run Code Online (Sandbox Code Playgroud)

//输出



如果所有三个字符串具有相同的内容,为什么所有字符串都没有在内存中相同的位置?

java string equality

7
推荐指数
1
解决办法
736
查看次数

数组索引超出范围

这就是我要做的事情:我正在从命令行读取文件.该文件包含一个数据列表,下面这段是它的样子.我遇到的问题是if语句.

import java.util.*;
import java.io.*;

public class VehicleTest {
    public static void main(String[] args) throws FileNotFoundException {
        String vehicle = "vehicle";
        String car = "car";
        String americanCar = "american car";
        String foreignCar = "foreign car";
        String truck = "truck";
        String bicycle = "bicycle";

        File file = new File(args[0]);
        Scanner input = new Scanner(file);

        String[] autos = new String[100];
        ArrayList allVehicles = new ArrayList();


        for (int i = 0; i < autos.length; i++) {
            autos[i] = input.nextLine();
        }

        int j = …
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
1
解决办法
2607
查看次数

为什么我在Java中遇到这个编译错误?

在java中为什么编译器不允许以下代码?

public class Test {

    public static void main(String[] args) {

        int x;
        int x = 4;// the error is generated here

    }

}
Run Code Online (Sandbox Code Playgroud)

java

-1
推荐指数
2
解决办法
201
查看次数

标签 统计

java ×4

equality ×1

keyword ×1

string ×1