如何将oneclass链接到另一个... [英] How to link oneclass to anotheri...
本文介绍了如何将oneclass链接到另一个...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我制作计算器的java项目
package 开发人员;
import java.util.Scanner;
public class ADD {
public static void main( String [] args){
int sum,a,b;
Scanner add = new Scanner(System.in);
System.out.println( 请输入第一个数字);
a = add.nextInt();
System.out.println( 请输入第二个数字);
b = add.nextInt();
sum = a + b;
System.out.println( 你的答案是 + sum);
}
}
和不同的classesmul.java,sub.java等等将一个类别链接到另一个类别
我尝试过:
i有不知道java类如何将
链接到另一个
解决方案
可能你不需要为每个操作单独的一个类,你可以写一个类,比如Calculator
,提供所有需要的操作作为方法。
无论如何,允许在同一个项目中使用很多类(我鼓励'鼓励',在Java
,只是 Google for ,以获得有用的信息(例如,参见在Java程序中使用多个类|简化编程 [ ^ ]。
here is my java project to make calculator
package developers; import java.util.Scanner; public class ADD { public static void main(String[] args) { int sum,a,b; Scanner add = new Scanner(System.in); System.out.println("Please enter first number "); a = add.nextInt(); System.out.println("Please enter second number "); b= add.nextInt(); sum=a+b; System.out.println("Your answer is "+sum); } }
and different classesmul.java,sub.java and so on how to link oneclass to another
What I have tried:
i have no idea about java class how
to link one to another解决方案Probably you don't need a separate class for each operation, you could write just one class, sayCalculator
, providing all the needed operation as methods.
Anyway, using many classes in the same project is allowed ('encouraged', I suppose) inJava
, just Google for, in order to get useful info (see, for instance Using multiple classes in Java program | Programming Simplified[^]).
这篇关于如何将oneclass链接到另一个...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文