JAVA的问题,紧急,大家帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/20 06:20:26
定义一个类,它包含了一个int类型的变量x,若干个构造函数(根据用户自己的需要)和一个输出方法show().编程:从键盘输入一个两位以上的数,将这个数传递给这个类的变量x,使用方法show()逆序输出这个数。

public class Test {
private int x;
private int result;

public Test() {
System.out.println("No input data...");
}

public Test(int x) {
this.x = x;
result = 0;
}

public void show() {
while(x>10) {
result = result*10 + x%10;
x /= 10;
}
result = result * 10 + x;
System.out.println("The result is :"+ result);
}
}

JAVA还没有学了

这么简单问题不作回答

给你写了一段程序:
package test;

//定义一个类,它包含了一个int类型的变量x,
//若干个构造函数(根据用户自己的需要)和一个输出方法show().
//编程:从键盘输入一个两位以上的数,将这个数传递给这个类的变量x,使用方法show()逆序输出这个数。

public class Test {

int x;

Test() {
super();
}

public void show() {
String temp = x + "";
String target = "";
for (int i = temp.length() - 1; i >= 0; i--) {
target += temp.charAt(i) + "";
}