小编Joe*_*hez的帖子

在文本文件中查找字符串的方法.然后将以下行达到一定限度

所以这就是我到目前为止所做的:

public String[] findStudentInfo(String studentNumber) {
                Student student = new Student();
                Scanner scanner = new Scanner("Student.txt");
                // Find the line that contains student Id
                // If not found keep on going through the file
                // If it finds it stop
                // Call parseStudentInfoFromLine get the number of courses
                // Create an array (lines) of size of the number of courses plus one
                // assign the line that the student Id was found to the first index value of the array …
Run Code Online (Sandbox Code Playgroud)

java methods file project

17
推荐指数
4
解决办法
14万
查看次数

用于确定字符串是否为十六进制数的递归方法 - Java

这是一个功课问题,我遇到了一些麻烦.

编写一个递归方法,确定String是否为十六进制数.为您的方法编写javadocs.如果每个字符为0或1或2或3或4或5或6或7或8或9或a或A或b或B或c或C或d或D或e,则字符串为十六进制数字或E或f或f.

目前,我只能看到测试这个,如果字符串0处的字符是他给我的这些值中的一个,那么它的一部分是十六进制.

任何提示或建议,以帮助我?

这是我到目前为止:`

public boolean isHex(String string){


    if (string.charAt(0)==//what goes here?){
        //call isHex again on s.substring(1)
    }else return false;
    }
Run Code Online (Sandbox Code Playgroud)

`

java methods recursion hex

3
推荐指数
1
解决办法
1454
查看次数

来自扫描仪的空白输入 - java

我想要做的是,如果用户点击回车键,程序应该抛出BadUserInputException.我的问题是,每当我按下回车键,它只是把我放在控制台的另一行,基本上什么都不做.

Scanner input = new Scanner(System.in);
    System.out.println("Enter Student ID:");

    String sID = null;
    if (input.hasNextInt()==false){
        System.out.println("Please re-check the student number inputted. Student number can only be digits.");
        throw new BadUserInputException("Student number can not contain non-digits.");
    }else if (input.next()==""){
        throw new BadUserInputException("Student number can not be empty");
    }
Run Code Online (Sandbox Code Playgroud)

java java.util.scanner

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

标签 统计

java ×3

methods ×2

file ×1

hex ×1

java.util.scanner ×1

project ×1

recursion ×1