老师我想从s数组角标为1的值开始,复制到sBak角标1的地方,打印的结果应该是:null 尚学堂 百度 京东 腾讯,null 但是这里运行为什么会报错啊,是我语法写的不对吗
构造方法会自动调用吗?还是跟普通方法一样得手动调用呢?记得有个方法可以自动调用呢,但是忘记是哪个了
string string1 = scanner.next();
这个是将什么内容赋值给string1?
难道是版本不对么?
20221223_变量.mp4
老师我的变量依旧无发出现
谢谢
老师,这个s.nextLine();是什么意思,什么作用?
为什么我的代码和视频的一模一样,跑出来的怎么不一样呢??
代码1:
class Teacher{ int teacherId; Person1 person1=new Person1(); public Teacher(int teacherId, Person1 person1) { this.teacherId = teacherId; this.person1 = person1; } }
代码2:
class Teacher { int teacherId; Person1 person1 = new Person1(); Teacher(int teacherId,String name,int height){ this.teacherId = teacherId; this.person1.name = name; this.person1.height = height; } }
其中Person1有两个属性:name、height
那么在构造器Teacher中两个代码的效果是不是一样的。
请问下老师,这样写的合理吗?
package com.tingting.test; /** * 测试组合component */ public class TestComponent { public static void main(String[] args) { Student s = new Student("高小其",165,"java"); } } class Person1{//类1 String name; int height; public void rest(){ System.out.println("我在休息!"); } } class Student /*extends Person1*/ {//类2 Person1 Person1 = new Person1(); String major;//专业 public void major() { System.out.println("我在尚学堂,学习Java"); } public Student(String name, int height, String major) { this.Person1.name = name; this.Person1.height = height; this.major = major; } }
老师为啥我这个类名还报错了
按视频来的 但是跟视频的结果不一样这是为啥啊 这个是什么问题啊
import java.util.Scanner; public class TaxCalculator { public static int taxCalculator(int a,int b){ int taxGet = (a-b-5000),tax; if (taxGet<3000){ tax = taxGet * 3% -0; }else if(taxGet<12000){ tax = taxGet * 10% -210; }else if (taxGet<25000){ tax = taxGet * 20% -1410; }else if (taxGet<35000){ tax = taxGet * 25% -2660; }else if (taxGet<55000){ tax = taxGet * 30% -4410; }else if (taxGet<80000){ tax = taxGet * 35% -7160; }else{ tax = taxGet * 45% -15160; } System.out.println("你的全年税为: "+tax*12); return tax; } public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("********月薪计算器********"); System.out.println("请输入月薪"); int monthSalary = s.nextInt(); System.out.println("请输入社会各项保险费"); int insurance = s.nextInt(); System.out.println("你的月薪是: "+monthSalary); System.out.println("你的社会各项保险是: "+insurance); taxCalculator(monthSalary,insurance); } }
老师,我试着用方法做了下,先写main再写方法没出现error,像上面代码一样先写方法就出现了如下的error,是什么原因呢?
老师它这个显示错误说无法解析方法login()是什么问题
记事本代码
老师那个BallGame game=new BallGame没懂是干嘛
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637