package Wmx;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
public class zifuoverLaod {
public static void main(String[] args) throws Exception {
try {
Reader reader=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(reader);
System.out.print("请输入第一个字符串:");
String str1=buf.readLine();
System.out.print("请输入第二个字符串:");
String str2=buf.readLine();
stOverLaod st=new stOverLaod();
st.stOver(str1, str2);
st.stOver(Integer.parseInt(str1),Integer.parseInt(str2));
st.stOver(Double.parseDouble(str1),Double.parseDouble(str2));
} catch (Exception e) {
System.out.println("输入不合法,请重新输入!");
}
}
}
class stOverLaod {
public void stOver(String str1,String str2) {
System.out.print("字符串拼接:");
System.out.println(str1+str2);
}
public void stOver(int str1,int str2) {
System.out.print("整数相加:");
System.out.println(str1+str2);
}
public void stOver(Double str1,Double str2) {
System.out.print("浮点数相加:");
System.out.println(str1+str2);
}
}
方法重载,字符拼接(java)
最新推荐文章于 2023-04-22 03:39:56 发布