:
:
Importer java.io.filenotfoundException; import java.io.ioexception; import java.util.arraylist; import java.util.concurrent.executorservice; importer java.util.concurrent.executors; / ** * créé par ysc le 7/26/16. * / interview de classe publique {private static void One () {String str1 = "Bonjour"; String str2 = "he" + new String ("llo"); System.err.println (str1 == str2); System.out.println ("1. False"); } private static void deux () {int i = Integer.max_value; System.err.println ((i + 1) <i); System.out.println ("2. 存在一个 i, 使得 (i + 1) <i"); } private static void trois () {System.err.println ("GC n'est pas un thread Java, c'est un thread natif"); Thread.getAllStackTraces (). KeySet (). ForEach (Thread -> System.out.println (Thread.GetName () + "->" + Thread.isDaemon () + "" + Thread.GetPriority ())); System.out.println ("3. GC 线程是 Daemon 线程"); } Int volatile statique privé = 0; private static void quatre () {exécutorService ExecutorService = exécutor.newcachedThreadpool (); pour (int j = 0; j <10; j ++) {exécutorService.Submit (() -> {for (int i = 0; i <1000000; i ++) {count ++;}}); } System.out.println ("Count doit être:" +10000000+ ", réel:" + count); System.out.println ("4. Volatile 不能保证线程安全"); } private static void cinq () {ArrayList <Integer> list = new ArrayList <> (20); list.add (1); System.out.println ("Code de débogage, pas d'exécution de la méthode de croissance"); System.out.println ("5. Liste se développe 0 fois"); } private static void six () {System.out.println ("Le constructeur de BufferedReader accepte uniquement une instance de lecture"); System.out.println ("6. new BufferedReader (new FileInputStream (/" a.dat / ")); est faux"); } private static void sept () {try {if (true) {throw new ioException (); }} catch (filenotfoundException e) {System.out.print ("filenotFoundException!"); } catch (ioException e) {System.out.print ("ioException!"); } catch (exception e) {System.out.print ("Exception!"); } System.out.println ("/ n7. IoException!"); } private static void huit () {System.out.println ("String S; System.out.println (s); Erreur: les variables S pourraient ne pas avoir été initialisées / nrecompile avec -xlint: sans contrôle pour plus de détails."); System.out.println ("8. 由于 String S 没有初始化, 代码不能编译通过"); } private static void nine () {System.out.println ("5" +2); System.out.println ("9. 52"); } private static void ten () {int i = 2; INT Result = 0; switch (i) {cas 1: résultat = résultat + i; Cas 2: résultat = résultat + i * 2; Cas 3: résultat = résultat + i * 3; } System.out.println ("result =" + résultat); System.out.println ("10. 10"); } classe statique privée null {public static void hello () {System.out.println ("Bonjour"); } public static void main (String [] args) {((null) null) .hello (); Null _null = (null) null; _null.hello (); }} classe statique privée stristExample1 {String str = new String ("GOOD"); char [] ch = {'a', 'b', 'c'}; public void change (String str, char [] ch) {str = "test ok"; ch [0] = 'g'; } public static void main (string [] args) {stristExample1 ex = new StringExample1 (); Ex.Change (Ex.str, Ex.CH); System.out.print (ex.str + "et"); System.out.print (Ex.CH); System.out.println (); }} classe statique privée stristExample2 {public static void change (string str) {str = "bienvenue"; } public static void main (string [] args) {String str = "1234"; changement (str); System.out.println (STR); }} classe statique privée forloop {statique booléen foo (char c) {System.out.print (c); Retour Vrai; } public static void main (String [] args) {int i = 0; for (foo ('a'); foo ('b') && (i <2); foo ('c')) {i ++; nourriture'); } System.out.println (); }} classe statique privée helloa {public helloa () {System.out.println ("helloa"); } {System.out.println ("Je suis une classe"); } statique {System.out.println ("statique a"); }} classe statique privée HelloB étend helloa {public helloB () {System.out.println ("helloB"); } {System.out.println ("Je suis B class"); } statique {System.out.println ("statique B"); } public static void main (String [] args) {System.out.println ("Main start"); new HelloB (); new HelloB (); System.out.println ("Main End"); }} public static void main (string [] args) {one (); deux(); trois(); quatre (); cinq(); six(); Sept(); huit(); neuf(); dix(); Null.main (null); StringExample1.Main (null); StringExample2.Main (null); Forloop.main (null); Hellob.main (null); }}以上就是本文的全部内容 , 希望对大家的学习有所帮助 , 也希望大家多多支持武林网。