JAVA
小钟好吧
全部回复
仅看楼主
level 6
小钟好吧 楼主
import java.util.Scanner;
class A {
int m1;
int f(int a,int b){
for(int i=1;i<=a&&i<=b;i++ )
{
double y1=a%i;
double y2=b%i;
if(y1==0&&y2==0)
{m1=i;}
}
return m1;
}
}
class B extends A{
int f(int a,int b){
return (a*b)/super.f(a,b);
}
}
public class C{
public static void main(String args[]){
Scanner reader =new Scanner(System.in);
int a= reader.nextInt();
int b=reader.nextInt();
if(a<0||b<0){
System.out.println("请输入正整数!!!");
System.exit(0);} A a1=new A();
System.out.printf("%d和%d的最大公约数为%d\n",a,b,a1.f(a,b));
B b1=new B ();
System.out.printf("%d和%d的最小公倍数为%d",a,b,b1.f(a,b));
}
}
2013年04月15日 11点04分 1
level 6
小钟好吧 楼主
菜鸟不容易[泪]
2013年04月15日 11点04分 2
level 6
小钟好吧 楼主
真心感受------>有bug问Robin,不然就重启。
2013年04月15日 11点04分 3
level 6
小钟好吧 楼主
(5.2)首先编写一个抽象类,要求该抽象类有三个抽象方法:
public abstract void f(int x);
public abstract void g(int x,int y);
public abstract double h(double x);
然后分别给出这个抽象类的三个子类。
要求:在应用程序的主类中使用这些子类创建对象,再让它们的上转型对象调用方法f()、g()和h()。
2013年04月18日 13点04分 4
level 6
小钟好吧 楼主
(5.3)编写一个类,要求该类实现一个接口,该接口有三个抽象方法:
public abstract void f(int x);
public abstract void g(int x,int y);
public abstract double h(double x);
要求:在应用程序的主类中使用该类创建对象,并使用接口回调来调用方法f()、g()和h()。
2013年04月18日 13点04分 5
level 6
小钟好吧 楼主
abstract class A{
public abstract void f(int x);
public abstract void g(int x,int y);
public abstract double h(double x); }
class A1 extends A{
public void f(int x){
System.out.println(""+x);
}
public void g(int x,int y){
System.out.printf("%d,%d\n",x,y);
}
public double h(double x){
return x;
}
}
class A2 extends A{
public void f(int x){
System.out.println(""+(x+1));
}
public void g(int x,int y){
System.out.printf("%d,%d\n",x+1,y+1);
}
public double h(double x){
return x+1;
}
}
class A3 extends A{
public void f(int x){
System.out.println(""+(x+2));
}
public void g(int x,int y){
System.out.printf("%d,%d\n",x+2,y+2);
}
public double h(double x){
return x+2;
}
} public class yang { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
A a;
a=new A1();
a.f(1);
a.g(1, 1);
System.out.println(""+a.h(1));
a=new A2();
a.f(1);
a.g(1, 1);
System.out.println(""+a.h(1));
a=new A3();
a.f(1);
a.g(1, 1);
System.out.println(+a.h(1));
} }
2013年04月23日 06点04分 6
level 6
小钟好吧 楼主
interface B{
public abstract void f(int x);
public abstract void g(int x,int y);
public abstract double h(double x); }
class B1 implements B{
public void f(int x){
System.out.printf("%d\n",x);
}
public void g(int x,int y){
System.out.printf("%d,%d\n",x,y);
}
public double h(double x){
return x;
}
}
public class Yang2 { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
B b;
b=new B1();
b.f(1);
b.g(1, 1);
System.out.println(""+b.h(1));
} }
2013年04月23日 07点04分 7
level 6
小钟好吧 楼主
建议学习
1.html+css+javascript
2.学习java基础如基本语法,变量,基本数据类型,堆和栈,数组,集合,循环
面向对象,封装,继承多态,接口, 抽象,包装类,异常,IO流
了解线程初步 (建议视频马士兵)
3.学习JDBC(李勇)
4.学习jsp+javaban+servlert或者javaweb开发
5.三大框架struts+hibernate+spring学完后借鉴springmvc,ibaits了解一下JBPM
以上视频传智播客都有 至于后期自己继续深造看个人,每天学习视频两小时,代码两小时
2013年04月24日 09点04分 8
level 6
小钟好吧 楼主
/*匿名类的用法与上转型对象相似*/
class A{
int i=1;
void f(){
System.out.println("dksjaflka");
}
}
public class Zhong { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub A a=new A(){
int i=3;
void f(){System.out.println("++++fgfdgdsfgfdsg="+i);}
};
a.f();
System.out.println(""+a.i);
} }
运行结果:
++++fgfdgdsfgfdsg=3
1
2013年05月02日 07点05分 9
level 6
小钟好吧 楼主
2013年05月02日 07点05分 10
level 6
小钟好吧 楼主
2013年05月07日 07点05分 11
level 6
小钟好吧 楼主
类object
的所有方法:
1. getClass()
2. hashCode()
3. equals()
4. toString()
5. clone()
6. wait()...
7. notify()
8. notifyAll()
9. finalize()
及各个方法作用:
protected Object clone() 创建并返回此对象的一个副本。
boolean equals(Object obj) 指示某个其他对象是否与此对象“相等”。
protected void finalize() 当垃圾回收器确定不存在对该对象的更多引用时,由对象的垃圾回收器调用此方法。
Class<? extendsObject> getClass() 返回一个对象的运行时类。
int hashCode() 返回该对象的哈希码值。
void notify() 唤醒在此对象监视器上等待的单个线程。
void notifyAll() 唤醒在此对象监视器上等待的所有线程。
String toString() 返回该对象的字符串表示。
void wait() 导致当前的线程等待,直到其他线程调用此对象的 notify() 方法或 notifyAll() 方法。
void wait(long timeout) 导致当前的线程等待,直到其他线程调用此对象的 notify() 方法或 notifyAll() 方法,或者超过指定的时间量。
void wait(long timeout, int nanos) 导致当前的线程等待,直到其他线程调用此对象的 notify()
2013年05月07日 07点05分 12
level 6
小钟好吧 楼主
java一百三十几个包,几千个类,系统默认的包java.lang中的主要类是object类,此类是所有类默认的父类。[我错了]
2013年05月07日 07点05分 13
level 6
小钟好吧 楼主
Java应用程序用户界面开发包Swing
2013年05月08日 14点05分 15
1