JAVA编程实例1、publicclassMyClass{privateintval1,val2;publicvoidmyFun(intx,inty){val1=x;val2=y;System.out.println("Thesumis:"+(val1+val2));}publicstaticvoidmain(Stringarg[]){MyClassMyObj=newMyClass();MyObj.myFun(1,2);}}运行结果如下:Thesumis:3