JAVArsovia w Polskim Radiu Euro

piórem Mariusza Lipińskiego
int[] nums = new int[16];
Thread[] threads = new Thread[4];
public class Test {
public static void main(String[] args) {
int[][] myTable = new int[4][];
myTable[0] = new int[2];
myTable[1] = new int[4];
myTable[2] = new int[6];
myTable[3] = new int[8];
}
}
public class Test {
public static void main(String[] args) {
int[][] myTable = new int[4][2];
myTable[1] = new int[4];
for(int[] subTable : myTable) {
for(int i : subTable)
System.out.print(i + " ");
System.out.println();
}
}
}
0 0
0 0 0 0
0 0
0 0
public class Test {
public static void main(String[] args) {
int x = 2;
triple(x);
System.out.println("x: " + x);
}
static void triple(int x) {
x *= 3;
}
}
public class Test {
public static void main(String[] args) {
SomeClass obj = new SomeClass();
triple(obj);
System.out.println("x: " + obj.getX());
}
static void triple(SomeClass obj) {
obj.setX(obj.getX() * 3);
}
}
class SomeClass {
int x = 2;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
}
public class Test {
public static void main(String[] args) {
SomeClass obj = new SomeClass();
triple(obj);
System.out.println("x: " + obj.getX());
}
static void triple(SomeClass obj) {
SomeClass localObj = new SomeClass();
localObj.setX(obj.getX() * 3);
obj = localObj;
}
}
class SomeClass {
private String descr = "default value";
public String getDescr() {
return descr;
}
public void setDescr(String descr) {
this.descr = descr;
}
}
public class Test {
public static void main(String[] args) {
testPrimitives();
testReferences();
}
static void testPrimitives() {
int x = 1;
int y = x;
x = 2;
System.out.println("y: " + y);
}
static void testReferences() {
SomeClass a = new SomeClass();
SomeClass b = a;
a.setDescr("new value");
System.out.println("b descr: " + b.getDescr());
}
}
public class Test {
static int x;
public static void main(String[] args) {
System.out.println(x);
}
}
public static void main(String[] args) {
int x;
System.out.println(x); // błąd!
}
public static void main(String[] args) {
int x;
if(args.length > 0)
x = 1;
System.out.println(x); // błąd!
}
public static void main(String[] args) {
int[] array = new int[16];
for(int x : array)
System.out.println(x);
}
public class Test {
public static void main(String[] args) {
SomeClass sc = new SomeClass();
System.out.println("someFloat: " + sc.someFloat
+ " doubleValue: " + sc.doubleValue);
}
}
class SomeClass {
Float someFloat;
double doubleValue;
}
Zapraszam na konferencję JAVArsovia 2008, która odbędzie się w dniu 31 maja w gmachu Wydziału Biologii Uniwersytetu Warszawskiego, przy ulicy Ilji Miecznikowa 1 w Warszawie. Zarejestruj się już dziś. Wstęp wolny!
public class Test {
String str = "Some text";
public static void main(String[] args) {
System.out.println(str); // błąd!
}
}
static long power(long base, long exponent) {
for(int x = 1, y = 0; y < exponent; y++) {
x *= base;
}
return x; // błąd!
}
byte b = -128; // poprawne dla wartości od -128 do 127
short s = 32767; // poprawne dla wartości od -32768 do 32767
float f = 1.1; // błąd!
float f = 1.1F; // może też być małe f zamiast F
float ff = (float) 1.1;
byte a = 1;
byte b = a + 1; // błąd!
byte c = 1 + 1;
byte d = 64 + 64; // błąd!
byte e = 1 + 1L; // błąd!
float a = 1.1f;
float b = a + 1.2f;
public class Test {
public static void main(String[] args) {
byte x = (byte)128;
int i = 1024;
byte y = (byte)i;
System.out.println("x = " + x + " y = " + y);
}
}
b = (byte) (b + 2); // rzutowanie jest konieczne!
b += 2;
class SomeClass {
static void printMessage() {
System.out.println("my message");
}
}
public class Test {
public static void main(String[] args) {
SomeClass obj = null;
obj.printMessage();
}
}
class Parent {
static String getDescr() {
return "parent";
}
}
class Child extends Parent {
static String getDescr() {
return "child";
}
}
public class Test {
public static void main(String[] args) {
Parent obj = new Parent();
System.out.println(obj.getDescr());
obj = new Child();
System.out.println(obj.getDescr());
}
}
abstract class Parent {
private String str;
Parent() {
this.str = "some data";
}
public String getStr() {
return str;
}
}
class Child extends Parent { }
public class Test {
public static void main(String[] args) {
Child child = new Child();
System.out.println(child.getStr());
}
}
abstract class Parent {
private String str;
Parent(String str) {
this.str = str;
}
public String getStr() {
return str;
}
}
class Child extends Parent {
Child() {
this("some text");
}
Child(String str) {
super(str);
}
}
public class Test {
public static void main(String[] args) {
Child child = new Child();
System.out.println(child.getStr());
child = new Child("another text");
System.out.println(child.getStr());
}
}
class Child extends Parent {
Child() {
super(doSomethingBefore());
}
static String doSomethingBefore() {
System.out.println("before call to super()");
return "some text";
}
}
class Parent {
String str = "some value";
}
class Child extends Parent {
String childStr = "some other value";
}
Specjalizuję się w doradztwie oraz wdrożeniach w zakresie kompleksowej integracji systemów, automatyzacji procesów biznesowych oraz przetwarzania danych, w szczególności, przy użyciu technologii Sztucznej Inteligencji. Jestem absolwentem studiów Informatycznych Uniwersytetu Warszawskiego oraz studiów podyplomowych Efektywnego Zarządzania IT w Przedsiębiorstwie Szkoły Głównej Handlowej w Warszawie.