public class BiJiao
{
?? boolean comp(Object a,Object b)
?? {
?? ? return a==b;
?? ?}
?? ?
?? ?boolean comp1(Object a,Object b)
?? ?{
?? ??return a.equals(b);
?? ?}
?? ?
??? boolean compInt(int i,int j)
?? ?{
?? ??return i==j;
?? ?}
?? ?
?? ?boolean compInt1(int i,int j)
?? ?{
?? ??return (Integer.valueOf(i)).equals(Integer.valueOf(j));
?? ?}
?? ?
??? public void biObject(Object a,Object b)
?? ?{
?? ??if(comp(a,b))
?? ??System.out.println("用\"==\"比較的結(jié)果:?????? "+"true");
?? ??else
?? ??System.out.println("用\"==\"比較的結(jié)果:?????? "+"false");
?? ??if(comp1(a,b))
?? ??System.out.println("用\"equals()\"比較的結(jié)果: "+"true");
?? ??else
?? ??System.out.println("用\"equals()\"比較的結(jié)果: "+"flase");
?? ?}
?? ?
?? ?public void biInt(int i,int j)
?? ?{
?? ??if(compInt(i,j))
?? ??System.out.println("用\"==\"比較的結(jié)果:?????? "+"true");
?? ??else
?? ??System.out.println("用\"==\"比較的結(jié)果:?????? "+"false");
?? ??if(compInt1(i,j))
?? ??System.out.println("用\"equals()\"比較的結(jié)果: "+"true");
?? ??else
?? ??System.out.println("用\"equals()\"比較的結(jié)果: "+"flase");
?? ?}
?? ??
?? ?public int test(String t)
?? ?? ?{
?? ?? ??int k=0;
?? ?? ?? String str="0123456789";
?? ?? ? for(int i=0;i<t.length();i++)
?? ?? ?{
?? ?? ??char ch1=(char)t.charAt(i);
?? ?? ??
?? ?? ??if(str.indexOf(ch1)==-1)
?? ?? ??? k++;
?? ?? ?}
?? ?? ?return k;
?? ??}
?? ??
?? ?public static void main(String[] args)
?? ?{
?? ?? BiJiao biJiao=new BiJiao();
?? ??
?? ?? if(args.length<2)
?? ?? {
?? ?? ?
?? ?? ? System.out.println("請輸入兩個字符或數(shù)字:");
?? ?? ? System.exit(0);
?? ?? ?}
?? ?? ?
?? ?? ?String a=args[0];
?? ?? ?String b=args[1];
?? ?? ?
?? ?? ?int k=biJiao.test(a);
?? ?? ?int p=biJiao.test(b);
?? ??
?? ?? ?
?? ?? ?if(k==0&&p==0)
?? ?? ?{
?? ?? ??System.out.println("您輸入的是數(shù)字:?????? "+a+" 和 "+b);
?? ?? ??int i=Integer.parseInt(a);
?? ?? ?? int j=Integer.parseInt(b);
?? ?? ??biJiao.biInt(i,j);
?? ?? ?}
?? ?? ?else
?? ?? ?? {
?? ?? ?? ?System.out.println("您輸入的是字符:???? "+a+" 和 "+b);
?? ?? ?? ?biJiao.biObject(a,b);
?? ?? ?? }
?? ?}
}
?? ?? ?