🗊Презентация Java Puzzlers

Нажмите для полного просмотра!
Java Puzzlers, слайд №1Java Puzzlers, слайд №2Java Puzzlers, слайд №3Java Puzzlers, слайд №4Java Puzzlers, слайд №5Java Puzzlers, слайд №6Java Puzzlers, слайд №7Java Puzzlers, слайд №8Java Puzzlers, слайд №9Java Puzzlers, слайд №10Java Puzzlers, слайд №11Java Puzzlers, слайд №12Java Puzzlers, слайд №13Java Puzzlers, слайд №14

Вы можете ознакомиться и скачать презентацию на тему Java Puzzlers. Доклад-сообщение содержит 14 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





Java Puzzlers
From the book Java Puzzlers
by Joshua Bloch and Neal Gafter
Описание слайда:
Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter

Слайд 2





Oddity
The following method tests whether its argument is odd:
public static boolean isOdd(int i) {
    return i % 2 == 1;
}
Does it work?

It gives the correct answer for ¾ of the integers
Описание слайда:
Oddity The following method tests whether its argument is odd: public static boolean isOdd(int i) { return i % 2 == 1; } Does it work? It gives the correct answer for ¾ of the integers

Слайд 3





Making change
public class Change {
    public static void main(String[] args) {
        System.out.println(2.00 - 1.10);
    }
}


0.8999999999999999
Описание слайда:
Making change public class Change { public static void main(String[] args) { System.out.println(2.00 - 1.10); } } 0.8999999999999999

Слайд 4





Long Division
public class LongDivision {
    public static void main(String[] args) {
        final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000;
        final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;
        System.out.println(MICROS_PER_DAY / MILLIS_PER_DAY);
    }
}


5
Описание слайда:
Long Division public class LongDivision { public static void main(String[] args) { final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000; final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000; System.out.println(MICROS_PER_DAY / MILLIS_PER_DAY); } } 5

Слайд 5





Addition
public class Addition {
    public static void main(String[] args) {
        System.out.println(12345 + 5432l);
    }
}


17777
Описание слайда:
Addition public class Addition { public static void main(String[] args) { System.out.println(12345 + 5432l); } } 17777

Слайд 6





Tweedledum
Declare variables x and i such that
     x += i;
is legal, but
     x = x + i;
is not legal

short x = 0;
int i = 123456;
Описание слайда:
Tweedledum Declare variables x and i such that x += i; is legal, but x = x + i; is not legal short x = 0; int i = 123456;

Слайд 7





Tweedledee
Declare variables x and i such that
     x = x + i;
is legal, but
     x += i;
is not legal

Object x = "Hello ";
String i = "world!";
Описание слайда:
Tweedledee Declare variables x and i such that x = x + i; is legal, but x += i; is not legal Object x = "Hello "; String i = "world!";

Слайд 8





+=
public class PlusEquals {
    public static void main(String[] args) {
        int i = 2;
        i += 3.75;
        System.out.println(i);
    }
}


5
Описание слайда:
+= public class PlusEquals { public static void main(String[] args) { int i = 2; i += 3.75; System.out.println(i); } } 5

Слайд 9





Last Laugh
public class LastLaugh {
    public static void main(String[] args) {
        System.out.print("H" + "a");
        System.out.print('H' + 'a');
    }
}


Ha169
Описание слайда:
Last Laugh public class LastLaugh { public static void main(String[] args) { System.out.print("H" + "a"); System.out.print('H' + 'a'); } } Ha169

Слайд 10





Indecision
public class Indecisive {
    public static void main(String[] args) {
        System.out.println(decision());
    }

    static boolean decision() {
        try {
            return true;
        }
        finally {
            return false;
        }
    }
}


false
Описание слайда:
Indecision public class Indecisive { public static void main(String[] args) { System.out.println(decision()); } static boolean decision() { try { return true; } finally { return false; } } } false

Слайд 11





HelloGoodbye
public class HelloGoodbye {
    public static void main(String[] args) {
        try {
            System.out.println("Hello world!");
            System.exit(0);
        }
        finally {
            System.out.println("Goodbye world!");
        }
    }
}


Hello world!
Описание слайда:
HelloGoodbye public class HelloGoodbye { public static void main(String[] args) { try { System.out.println("Hello world!"); System.exit(0); } finally { System.out.println("Goodbye world!"); } } } Hello world!

Слайд 12





The reluctant constructor
public class Reluctant {
    private Reluctant internalInstance = new Reluctant();

    public Reluctant() throws Exception {
        throw new Exception("I'm not coming out!");
    }
    public static void main(String[] args) {
        try {
            Reluctant b = new Reluctant();
            System.out.println("Surprise!");
        }
        catch (Exception e) {
            System.out.println("I told you so.");
        }
    }
}


Exception in thread "main" java.lang.StackOverflowError
Описание слайда:
The reluctant constructor public class Reluctant { private Reluctant internalInstance = new Reluctant(); public Reluctant() throws Exception { throw new Exception("I'm not coming out!"); } public static void main(String[] args) { try { Reluctant b = new Reluctant(); System.out.println("Surprise!"); } catch (Exception e) { System.out.println("I told you so."); } } } Exception in thread "main" java.lang.StackOverflowError

Слайд 13





Hello again
public class Null {
    public static void main(String[] args) {
        ((Null)null).greet();
    }

    public static void greet() {
        System.out.println("Hello world!");
    }
}

Hello world!
Описание слайда:
Hello again public class Null { public static void main(String[] args) { ((Null)null).greet(); } public static void greet() { System.out.println("Hello world!"); } } Hello world!

Слайд 14





The End
Описание слайда:
The End



Теги Java Puzzlers
Похожие презентации
Mypresentation.ru
Загрузить презентацию