Java stuff. Part 1
There are some java stuff under the cut.

1.0 - 0.9

class DotNine 
{
	static public void main(String[] args) 
	{
		System.out.println(1.0 - 0.9);
		// Prints 0.09999999999999998
		
		System.out.println(
			1.0 == 0.99999999999999998
			? "equals" 
			: "not equals"
			);
		// Prints equals
	} 
	
}

Double return in try and finally


public class TryOrFinally {
	
	static public void main(String[] args) {
		TryOrFinally tof = new TryOrFinally();
		System.out.println(tof.tryOrFinally());
		// Prints finally
	}
	
	@SuppressWarnings("finally")
	public String tryOrFinally() {
		try {
			return "try";
		}
		finally {
			return "finally";
		}
		
	}

}

Priority of signatures



public class VarArgs {
	
	static public void main(String[] args) {
		VarArgs va = new VarArgs();
		va.say("q", "w", "e");
		// Prints Const length q w e
	}
	
	public void say(String a, String b, String c) {
		System.out.println(String.format("Const length %s %s %s", a, b, c));
	}
	
	public void say(String ...s) {
		System.out.print("Var length ");
		for (int i = 0; i < s.length; i++) {
			System.out.print(s[i] + " ");
		}
		
	}
	
}
May 6rd, 2011
Back to main
Moi krug - Yernat Assanov
Advertisement
Documentolog
(C) 2010, kseeker
Email: kseeker@yandex.kz
Используются технологии uCoz