假设我想将两个程序合二为一,这样当我运行组合程序时,各个程序的两个输出都会被打印出来。我如何编写代码来实现这一点?
方案一:
public class Number1 {
public static void main (String[] args){
double s0=1.0;
double v0=2.0;
double a=9.8;
double t=3.0;
double s;
System.out.println(s0+v0*t+0.5*a*t*t);
}
}
方案二:
public class Number2 {
public static void main (String[] args) {
for (int i=1; i<=10; i++){
System.out.print(i*i + " ");
}
System.out.println("");
}
}