java 小程序问题

466关注814浏览

import java.io.*;
class Student
{
static String name;
static String StudentID;
static int record;
static void SetRecord()
{
name="jack";
StudentID="007";
record=90;
}
stati

展开全部
收起
4回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • 八角与丁香

    15人对此回答表示赞同

    String inStr1 = new String(buf,0,bytes);

    -->String inStr1 = new String(buf,0,StudentID.length());

    原因:数组大小为255,bytes = System.in.read(buf,0,255);这样会把你最后输入的空格也算上,
    String inStr1 = new String(buf,0,bytes);这样的话inStr1的值肯定不等于Studen
    展开
    15
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • Jose

    4人对此回答表示赞同

    这个不是你的if语句除了问题,而是你的输入有问题
    bytes = System.in.read(buf,0,255)是字节流,你输入完毕后按回车,也会输入一个“ ”
    所以if判断永远是不相同的,这里你应该用字符流

    import java.io.*;

    class Student {
        static String name;
    &nb

    展开
    4
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • Ezekiel

    3人对此回答表示赞同

    不要用System.in.read(buf,0,255);作为后台输入,这种做法你要彻底放弃。
    使用java.util.Scanner sc=new java.util.Scanner(System.in);
    int i=sc.nextInt();
    String str=sc.next();
    String str2=sc.nextLine();
    double d=sc.nextDouble();
    展开
    3
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • 李斯年

    1人对此回答表示赞同

    String inStr1 = new String(buf,0,bytes);这句话有问题,bytes的长度始终都比你输入的要大两个,所以你这样String inStr1 = new String(buf,0,bytes-2);就行了
    展开
    1
    0回复
    发布于 6年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部