Pokazywanie postów oznaczonych etykietą short-cut operator. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą short-cut operator. Pokaż wszystkie posty

12 mar 2010

If &&,||,|,&


@Test
public void test1() {


//kwestia && i & w if
if(True("1") &&True("2") & True("3")){} // 1 2 3
if(False("1") &&True("2") & True("3")){} // 1 !!!!!!!!
if(True("1") &&False("2") & True("3")){} // 1 2 3
if(True("1") &&False("2") && True("3")){} // 1 2
if(False("1") & True("3")){} // 1 3

//kwestia || i |
if(True("1") || False("2")){}//1
if(True("1") | False("2")){}//1 2

if(False("1") ||False("2") && False("3")){} // 1 2
if(False("1") ||False("2") | False("3")){} // 1 2 2

}

public boolean True(String msg ){
System.out.println(msg);
return true;

}
public boolean False(String msg ){
System.out.println(msg);
return false;
}

9 mar 2010

Haczyki v2


if(20%4){} //zonk bo wynikiem jest int!!


String s = null; /* Nie bedzie NullPointerException!!!!!!!!!*/
String result = s != null && s.equals("test") ? "yes" : "no";

  1. Kwestia || i | w jednym ifie + kwsestia && i & w jednym ifie
  2. Jeśli casy w switchu się powtórzą to! => compilation error!!!!!!!!!