<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    例題分析(2)

    21。
    import java.io.BufferedReader;
    import java.io.InputStreamReader;

    public class Qipaofa {

    ?public static void main(String[] args) {
    ??int i,j;
    ??int a[] = {30,1,-9,40,25};??
    ??int n = a.length;
    ??for( i = 1;i < n; i++){
    ???for( j = 0; j < n-1; j++)
    ????if(a[j] > a[j+1]){
    ?????int t = a[j];
    ?????a[j] = a[j+1];
    ?????a[j+1] = t;
    ????}
    ??}
    ??for( i = 0; i<n; i++)
    ???System.out.println(a[i]+"");
    ?}

    }


    22。
    public class Quiz {


    ?public static void main(String[] args) {
    ?try{
    ??try{
    ???int i;
    ???int j=0;
    ???i = 1 / j;
    ??}catch(Exception e){
    ???System.out.print("a");
    ???throw e;
    ??}finally{
    ???System.out.print("inside");
    ??}
    ???}catch(Exception e){
    ????System.out.print("CaughB");
    ???}finally{
    ????System.out.print("OutSide");
    ???}

    ?}

    }



    23.
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    public class Reverse {


    ?public static void main(String[] args) {
    ??int i,n = 10;
    ??int a[] = new int[10];
    ??for (i = 0;i<n; i++)
    ??try{
    ???BufferedReader br = new BufferedReader(
    ?????new InputStreamReader(System.in));
    ???a[i] = Integer.parseInt(br.readLine());
    ??}catch(IOException e){};
    ??for (i = n-1; i>=0; i--)
    ???System.out.println(a[i]+" ");
    ??System.out.println();

    ?}

    }



    24.
    public class Sample {
    String length;

    public Sample(String l){length = l;}
    ?public static void main(String[] args) {
    ??Sample s1,s2,s3;
    ??s1 = new Sample("aa");
    ??s2 = new Sample("aa");
    ??s3 = s2;
    ??long m = 21L;
    ??int k = 88;
    ??String n = "aa";
    ??if(s1==s2)
    ???System.out.println("s1==s2");
    ??if(s2==s3)
    ???System.out.println("s2==s3");
    //??if(k==s1)
    //??System.out.println("m==s1");
    ??if(s1.equals(s2))
    ???System.out.println("s1.equals(s2)");
    ??
    ?}

    }



    25.
    class SplitString

    {

    String SplitStr;

    int SplitByte;

    public SplitString(String str,int bytes)

    {

    SplitStr=str;

    SplitByte=bytes;

    System.out.println("The String is:′"+SplitStr+"′;SplitBytes="+SplitByte);

    }

    public void SplitIt()

    {

    int loopCount;

    loopCount=(SplitStr.length()%SplitByte==0)?(SplitStr.length()/SplitByte):(SplitStr.length()/SplitByte+1);

    System.out.println("Will Split into "+loopCount);

    for (int i=1;i<=loopCount ;i++ )

    {

    if (i==loopCount){

    System.out.println(SplitStr.substring((i-1)*SplitByte,SplitStr.length()));

    } else {

    System.out.println(SplitStr.substring((i-1)*SplitByte,(i*SplitByte)));

    }

    }

    }

    public static void main(String[] args)

    {

    ?SplitString ss = new SplitString("test中dd文dsaf中男大3443n中國43中國人 0ewldfls=103",4);

    ss.SplitIt();

    }

    }


    26.
    public class StringText {

    ?/**
    ? * @param args
    ? */
    ?public static void main(String[] args) {
    ??? String a ="Gone With Wind";
    ??? String t= "Wind";
    ??? String m;
    //??? m=a-t;
    //??? m=a[3]+"one";
    ??? m=a.toUpperCase();

    ?}

    }


    27.
    class Vehicle1{
    ?public void drive(){
    ??System.out.println("Vehicle1:drive");
    ?}
    }
    class Car1 extends Vehicle1{
    ?public void drive(){
    ??System.out.println("Car1:drive");
    ?}
    }
    public class Test {
    ?public static void main(String[] args) {

    ??Vehicle1 v;
    ??Car1 c;
    ??v=new Vehicle1();
    ??c = new Car1();
    ??v.drive();
    ??System.out.println("1");
    ??c.drive();
    ??System.out.println("2");
    ??v = c;//把地址c給了v
    ??System.out.println("3");
    ??v.drive();
    ??System.out.println("xiang shang zhuan xing ");
    ??v=(Vehicle1)c;
    ??System.out.println("no using");
    ??v.drive();
    ?}

    }


    28.
    class Example{
    ?String str;
    ?public Example(){
    ??str = "example";
    ?}
    ?public Example(String s){
    ??str = s;
    ??System.out.println("aa");
    //??System.out.println("asd"+m);
    ?}
    }
    class Demo extends Example{}
    public class test1 {

    ?public static void f(){
    ??
    ??Example ex = new Example("Good");
    //??Demo d = new Demo("Good");//只能新方法或者重載調用"Good"
    ?}
    ?public static void main(String[] args) {
    ??f();
    ?}

    }



    29.
    public class Test2 {
    public void aa(int i, int j){
    ?System.out.println("a");
    }
    public void Aa(int i, int j){
    ?System.out.println("A");
    }
    ?public static void main(String[] args) {
    ??// TODO Auto-generated method stub
    ??Test2 t2 = new Test2();
    ??t2.Aa(5,3);
    ??t2.aa(3,1);
    ?}

    }



    30.
    import java.util.Date;

    class?? super1{??
    ?????? {??
    ??????????????? System.out.println("super1?? ok");??
    ??????? }??
    ??????? super1()?? {??
    ?????????? System.out.println("3");??
    ?????? }??
    ?? }??
    ???
    ? class?? Employee?? extends?? super1{??
    ???????????? private?? String?? name;??
    ???????????? private?? double?? salary=1500.00;??
    ???????????? private?? Date?? birthday;??
    //???????????? public?? Employee(){??
    //???????????? ?System.out.println("3");?
    //???????????? }?? 這里不會被執行。。。
    ??????????? public?? Employee(String?? n,Date?? DoB){??
    ??????????????? System.out.println("2");??
    ??????????????? name=n;??
    ??????????????? birthday=DoB;??
    ??????????? }??
    ???????????? public?? Employee(String?? n){??
    ???????????????? this(n,null);??
    ???????????????? System.out.println("4");??
    ???????????? }??
    ?? }
    ?? class?? Manager?? extends?? Employee{??
    ????? {??
    ?????????? System.out.println("Manager?? ok");??
    ?????? }?
    ????? int b =3;
    ????? private?? String?? department;??
    ?????? public?? Manager(String?? n,String?? d){
    ??? ???
    ???????????? super(n);
    ???????????? System.out.println("a");?
    ???????????? department=d;??
    ?????? }?
    ?? }
    ????
    ?? public?? class?? Test3{??
    ?????? public?? static?? void?? main(String?? args[]){??
    ???????????? new?? Manager("Smith","sales");??
    ?????? }??
    ?? }


    31.
    class testB {
    ??? public testB(){
    ???? a1();
    ?? }
    ??? public void a1() {
    ????? System.out.println("A-a1");
    ??? }
    ????
    ? }
    ??
    ? public class TestA extends testB{
    ??? int bb=0;
    ??? public TestA() {
    ???? bb=1000;
    ??? }
    ??? public void a1() {
    ???? System.out.println("bb is"+bb);
    ????? System.out.println("B-a1");
    ??? }
    ??? public static void main(String[] args) {
    ????? new TestA();
    ??? }
    ??
    ? }


    32.
    public class TestException {
    ?public static void f1(){
    ??try{
    ???f2();
    ???System.out.println("f2 complete");
    ??}catch(Throwable t){}
    ?}
    ?public static void f2(){
    ??int x= 0;
    ??int i = 12 / x;
    ??System.out.println("division by zero........");
    ?}
    ?public static void main(String[] args) {
    ??
    ?f1();
    //?TestException x = new TestException();
    //?x.f1();
    ?System.out.println("f1 complete");

    ?}
    }



    33.
    public class WeiZhi {

    ?public static void main(String[] args) {
    ??String a = "abcabcbcadf";
    ??int n = a.indexOf("a");
    ??int m = a.lastIndexOf("a");
    ??System.out.println(n);
    ??System.out.println(m);
    ??System.out.print(a.length());
    //??int k =a.length() - a.f(x);
    ??String k = a.substring(1,5);
    ??System.out.println(k);
    ?}

    }



    34.
    public class Xiabiao {

    ?/**
    ? * @param args
    ? */
    ?public static void main(String[] args) {
    ?int i,s =0;
    ?int a[] = {10,20,30,40,50,60,70,80,90};
    ?for (i = 0; i< a.length;i++)
    ??if(a[i]%3 == 0) s += a[i];
    ?System.out.println("s="+s);
    ?}

    }


    35.
    public class Xunhuan {

    ?public static void main(String[] args) {
    ??int i,j;
    //??lab:
    ???for(i = 0;i < 6;i++){
    ???for(j = 5; j > 2; j--){
    ????if(i == j){
    ?????System.out.println(""+j);
    //?????continue lab;
    ????}
    ???}
    ??}

    ?}

    }

    posted on 2006-12-24 15:44 youngturk 閱讀(234) 評論(0)  編輯  收藏 所屬分類: 個人隨筆總結

    <2006年12月>
    262728293012
    3456789
    10111213141516
    17181920212223
    24252627282930
    31123456

    導航

    統計

    公告

    this year :
    1 jQuery
    2 freemarker
    3 框架結構
    4 口語英語

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    相冊

    EJB學習

    Flex學習

    learn English

    oracle

    spring MVC web service

    SQL

    Struts

    生活保健

    解析文件

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲免费人成在线视频观看| 亚洲av午夜电影在线观看| 天天操夜夜操免费视频| 一日本道a高清免费播放| 亚洲人成77777在线观看网| 亚洲av无码乱码在线观看野外| 久久综合国产乱子伦精品免费 | 三级黄色片免费看| 亚洲国产成人手机在线观看| 亚洲狠狠狠一区二区三区| 亚洲一级片免费看| 亚洲精品国产va在线观看蜜芽| 国产高清不卡免费在线| 亚洲视频在线免费播放| 99热这里只有精品免费播放| 久久久久免费精品国产| 国产成人AV免费观看| a国产成人免费视频| 99久久免费中文字幕精品| 中文无码成人免费视频在线观看| eeuss影院www天堂免费| 中文字幕无码毛片免费看| 人人揉揉香蕉大免费不卡| 两个人看的www免费视频中文| 中文字幕无码毛片免费看| 中文字幕免费在线观看| 精品香蕉在线观看免费| 国产精品99久久免费| 亚洲视频一区二区| 亚洲精品美女在线观看播放| 亚洲中文字幕精品久久| 成年免费大片黄在线观看com| 国产精品免费观看调教网| 精品免费久久久久久久| 免费人成激情视频| 亚洲国产精品无码中文字| 亚洲人成小说网站色| 色老头综合免费视频| 国产妇乱子伦视频免费| 亚洲国产精品丝袜在线观看| 久久亚洲一区二区|