我是这个网站的新手,我是 java 的初学者。我正在制作一个程序,它需要 5 个数字并将它们吐出。为什么这段代码不起作用?这是 2 中的第一个 .java。我在我认为问题所在的地方做了标记。
public class digitExtractor {
int tNumber;
String sNumber;
// OP thinks the problem is here...
public digitExtractor(int tNumber) {
}
// ... and here
public digitExtractor(String sNumber) {
}
public void returnInvertedOrderByMath() {
int Integer1;
int Integer2;
int Integer3;
int Integer4;
int Integer5;
Integer1 = (tNumber % 10);
Integer2 = (tNumber % 100) / 10;
Integer3 = (tNumber % 1000) / 100;
Integer4 = (tNumber % 10000) / 1000;
Integer5 = (tNumber % 100000) /10000;
System.out.println(Integer1 + "\n" + Integer2 + "\n" + Integer3 + "\n" + Integer4 + "\n" + Integer5);
}
public void returnInvertedOrderByString() {
char part1;
char part2;
char part3;
char part4;
char part5;
part1 = sNumber.charAt(4);
part2 = sNumber.charAt(3);
part3 = sNumber.charAt(2);
part4 = sNumber.charAt(1);
part5 = sNumber.charAt(0);
System.out.println(part1 + "\n" + part2 + "\n" + part3 + "\n" + part4 + "\n" + part5);
}
}