class Math {
void Book1(char a, char b) {
int c = a + b;
System.out.println("Output is" + c);
}
public static void main(String[] args) {
Math m = new Math();
m.Book1('A', 'B');
}
}
您可以按照以下步骤进行操作:
public class Math {
void Book1(char a, char b) {
StringBuilder sb=new StringBuilder();
sb.append(a);
sb.append(b);
System.out.println("Output is: " + sb.toString());
}
public static void main(String[] args) {
Math m = new Math();
m.Book1('A', 'B');
}
}
另外,您可以String
按以下方式使用类:
public class Math {
void Book1(char a, char b) {
String str=String.valueOf(a)+String.valueOf(b);
System.out.println("Output is: " + str);
}
public static void main(String[] args) {
Math m = new Math();
m.Book1('A', 'B');
}
}
输出:
Output is: AB
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句