主题:Java 编程小问题,高手帮助下菜鸟
package Test3;
import java.util.Scanner;
class Cat
{
public int age;
String st= new String();
public void act()
{
System.out.println("this cat is "+st+age+"old");
}
}
public class Te1
{ //根据用户输入的内容,给字符串赋值
String st1 = new String();
int age1;
Scanner sc = new Scanner(System.in);
age1=sc.nextInt();
st1=sc. //给字符串赋值 就是不知道这该如何写下去
public static void main(String []args)
{
Cat ca =new Cat();
}
}
就这了,麻烦高手指教
import java.util.Scanner;
class Cat
{
public int age;
String st= new String();
public void act()
{
System.out.println("this cat is "+st+age+"old");
}
}
public class Te1
{ //根据用户输入的内容,给字符串赋值
String st1 = new String();
int age1;
Scanner sc = new Scanner(System.in);
age1=sc.nextInt();
st1=sc. //给字符串赋值 就是不知道这该如何写下去
public static void main(String []args)
{
Cat ca =new Cat();
}
}
就这了,麻烦高手指教