Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 01 ====================================================================================================
- BigDecimal a = new BigDecimal("500.000");
- BigDecimal b = new BigDecimal("300000");
- System.out.println(a+b);
- 02 ====================================================================================================
- String s1 = "String";
- String s2 = new String("String");
- String s3 = "String";
- System.out.println(s1 == s2);
- System.out.println(s1 == "String");
- System.out.println(s1 == s3);
- System.out.println(s1.equals(s2));
- 03 ====================================================================================================
- private class myString extends String {
- public void sayHello () {
- System.out.println("Hello");
- }
- }
- 04 ====================================================================================================
- public class Item {
- int id;
- String name;
- }
- List<Item> list = new ArrayList();
- // заполняем лист...
- // как найти элемент с определенным name?
- 05 ====================================================================================================
- long[] array = {1, 2, 3};
- for (int x : array) {
- System.out.print(x);
- }
- 06 ====================================================================================================
- try {
- // do something
- return;
- } catch (Exception e) {
- // do something
- } finally {
- System.out.println("Finally block");
- }
- 07 ====================================================================================================
- try {
- // do something
- System.exit();
- } catch (Exception e) {
- // do something
- } finally {
- System.out.println("Finally block");
- }
- 08 ====================================================================================================
- public class Test {
- static {
- i = 5;
- }
- static int i = 6;
- public static void main(String[] args) {
- System.out.print(i);
- }
- }
- 09 ====================================================================================================
- private static class A {
- static int i = 1;
- }
- private static class B extends A {
- }
- A a = new A();
- a.i = 2;
- B b = new B();
- System.out.println(b.i);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement