java基础啊


public class Person {

String name;

int age;

String school;

String major;

public  Person(String n,int a) {

name=n;

age=a;

}

public  Person(String n,int a,String s) {

name=n;

age=a;

school=s;

}

public  Person(String n,int a,String s,String m) {

name=n;

age=a;

school=s;

major=m;

}}

class TestPerson{

public static void main(String[]args) {

Person one=new Person("花花",15,"中学","体育");

System.out.println(one.name,one.age,one.school,one.major);

}

}

它提示我这个错误 怎么解决   感谢

The method println(int) in the type PrintStream is not applicable for the arguments (String, int, String, String)

你不是最丑的
浏览 1984回答 3
3回答

qq_清影无痕_0

提示说的很清楚了,println这个方法不支持多参数,用逗号分隔相当于添加了多个参数,如果想实现输出,就把几个变量合成一个就可以了,字符串与整数可以直接用加号进行合并

慕莱坞8333017

3287400722175205418765086273181074275321640265326654053540078782270396816006569820872194391732265100112554510253991216593054154064439138732110753357001804675110095574249791398217754393142893216658954300770106522077175608973306510943997978480732153933984405883298331651109928731387247194399486219651371951175154865118624354098

qq_木偶_2

println()括号里逗号换成+试试
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java