What I learned with Java Gold

Describe what you learned in Java Gold along with the Java SE8 Gold problem collection (Kuromoto).

Chapter 1 Java Class Design

package tryAny.diamondExtends;

public interface A {
    default void x() {
	System.out.println("I am A.");
    }
}
package tryAny.diamondExtends;

public interface B extends A {

}
package tryAny.diamondExtends;

public interface C extends A {
    default void x() {
	System.out.println("I am C.");
    }
}
package tryAny.diamondExtends;

public class DiamondExtends implements B, C {
    public static void main(String[] args) {
	DiamondExtends de = new DiamondExtends();
	de.x();// I am C.Output
    }
}
package tryAny.inner;

public class InnerTest {
    class InnerA {
	void innerMethod() {
	    System.out.println("I am inner.");
	}
    }

    private void execInner() {
	InnerA ia = new InnerA();
	ia.innerMethod();
    }

    public static void main(String[] args) {
	InnerTest it = new InnerTest();
	it.execInner();
    }
}
package tryAny.inner;

public class Other {
    public static void main(String[] args) {
	InnerTest.InnerA ia = new InnerTest().new InnerA();
	ia.innerMethod();
    }
}
package tryAny.anonymous;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class AnonymousTest {
    public static void main(String[] args) {
	Data d1 = new Data(3, "aaa");
	Data d2 = new Data(1, "bbb");
	Data d3 = new Data(2, "ccc");

	List<Data> list = new ArrayList<Data>();
	list.add(d1);
	list.add(d2);
	list.add(d3);

	list.stream().forEach(System.out::println);// 3,1,Displayed in order of 2

	list.sort(new Comparator<Data>() {
	    public int compare(Data data1, Data data2) {
		if (data1.num > data2.num) {
		    return 1;
		} else {
		    return -1;
		}
	    }
	});

	list.stream().forEach(System.out::println);// 1,2,Display in order of 3
    }

    static class Data {
	int num;
	String value;

	Data(int num, String value) {
	    this.num = num;
	    this.value = value;
	}

	@Override
	public String toString() {
	    return num + ":" + value;
	}
    }
}
package tryAny.enumTes;

public enum Gender {
    MAN, WOMAN, OTHER;
}

class Try {
    public static void main(String[] args) {
	System.out.println(Gender.MAN.toString());// MAN
	System.out.println(Gender.MAN.name());// MAN
	for (Gender g : Gender.values()) {
	    System.out.println(g.name() + ":" + g.ordinal());
	    /**
	     * MAN:0 </br>
	     * WOMAN:1 </br>
	     * OTHER:2
	     */
	}
	Gender g = Gender.MAN;

	trans(g);//Man
    }

    public static void trans(Gender g) {
	switch (g) {
	case MAN:
	    System.out.println("Man");
	    break;
	case WOMAN:
	    System.out.println("woman");
	    break;
	case OTHER:
	    System.out.println("Other");
	    break;
	default:
	    assert (false);
	}
    }
}

Chapter 2 Collection and Generics

Foo<Integer> foo = new Foo<>();
package tryAny.Generic;

public class GenericTest<T> {
    /**
     *This can be compiled because T at the time of class declaration and T in the method below are different.
     */
    static <T> T exec3(T t) {
	return t;
    }

    /**The following does not compile
    static T exec(T t) {
	return t;
    }
    **/
}
//T is limited to the Number subtype.
class Foo<T extends Number> {}
package tryAny.Generic;

public class BoundedType {
    public static void main(String[] args) {
	Hoge<Foo, Bar> h1 = new Hoge<Foo, Bar>();//Compile through
	Hoge<Foo, Foo> h2 = new Hoge<Foo, Foo>();//Compile through
	// Hoge<Bar, Foo> h3 = new Hoge<Bar, Foo>();//Does not compile
    }
}

abstract class Foo {
}

class Bar extends Foo {
}

class Hoge<T, U extends T> {
}
package tryAny.lambda;

public interface Flyable {
    AirPlane getAirPlane(String name);
}
package tryAny.lambda;

public class LambdaTest6 {
    public static void main(String[] args) {
        Flyable f = AirPlane::new;
        AirPlane ap = f.getAirPlane("ana");

        System.out.println(ap);
    }
}

class AirPlane {
    private String name;

    public AirPlane(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "constructor " + this.name;
    }
}

Chapter 3 Lambda Expressions and Built-in Functional Interfaces

package tryAny.lambda;

public class LambdaTest {
    public static void main(String[] args) {
	Runnable r1 = new Runnable() {
	    public void run() {
		System.out.println("run1");
	    }
	};

	//the same
	Runnable r2 = () -> System.out.println("run2");

	Thread t1 = new Thread(r1);
	Thread t2 = new Thread(r2);
	t1.start();
	t2.start();
    }
}
package tryAny.lambda;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class LambdaTest2 {
    public static void main(String[] args) {
	Supplier<String> s = () -> "supplier";
	Predicate<String> p = str -> "supplier".equals(str);
	Consumer<String> c = str -> System.out.println(str);
	Function<String, Integer> f = str -> str.length();

	// "supplier"The number of characters of.
	if (p.test(s.get())) {
	    c.accept(f.apply(s.get()).toString());
	}
    }
}
package tryAny.lambda;

import java.util.function.IntFunction;
import java.util.function.IntUnaryOperator;
import java.util.stream.IntStream;

public class LambdaTest3 {
    public static void main(String[] args) {
        IntStream s1 = IntStream.of(1, 2, 3);
        IntFunction<IntUnaryOperator> func = x -> y -> x + y;

        IntStream s2 = s1.map(func.apply(2));
        s2.forEach(System.out::println);
    }
}

Chapter 4 Stream API

package tryAny.stream;

import java.util.Arrays;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class StreamTest1 {
    public static void main(String[] args) {
	String[] strAry = { "a", "b", "c" };
	Stream<String> strStream = Arrays.stream(strAry);
	strStream.forEach(System.out::println);

	int[] intAry = { 1, 2, 3, 4, 5 };
	IntStream intStream = Arrays.stream(intAry);
	intStream.forEach(System.out::println);

	IntStream intStream2 = Arrays.stream(intAry, 2, 4);
	intStream2.forEach(System.out::println);
	/**
	 * 3</br>
	 * 4
	 */

	IntStream.range(0, 4).forEach(System.out::print);// 0123
	IntStream.rangeClosed(0, 4).forEach(System.out::print);// 01234

    }
}
package tryAny.stream;

import java.util.stream.Stream;

public class StreamTest2 {
    public static void main(String[] args) {

	Stream<Data> s = Stream.of(new StreamTest2().new Data("a", 1), new StreamTest2().new Data("b", 2));
	// "a:1 b:2 "

	s.forEach(System.out::print);
    }

    class Data {
	String str;
	int i;

	public Data(String s, int i) {
	    this.str = s;
	    this.i = i;
	}

	@Override
	public String toString() {
	    return this.str + ":" + this.i + "  ";
	}
    }
}
package tryAny.stream;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class StreamTest3 {
    public static void main(String[] args) {
	try (BufferedReader br = new BufferedReader(new FileReader("src/main/java/tryAny/stream/sample.txt"))) {
	    br.lines().forEach(System.out::println);

	    Files.lines(Paths.get("src/main/java/tryAny/stream/sample.txt")).forEach(System.out::println);
	} catch (IOException e) {
	    e.printStackTrace();
	}

    }
}
package tryAny.lambda;

import java.util.Arrays;
import java.util.stream.IntStream;

public class LambdaTest4 {
    public static void main(String[] args) {
        int[][] data = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
        IntStream s1 = Arrays.stream(data).flatMapToInt(Arrays::stream);
        s1.forEach(System.out::print);// 123456
    }
}
package tryAny.stream;

import java.util.Arrays;
import java.util.List;

public class StreamTest5 {
    public static void main(String[] args) {
	List<List<String>> l = Arrays.asList(Arrays.asList("banana", "apple"), Arrays.asList("banana", "orange"));

	l.stream().flatMap(li -> li.stream()).distinct().forEach(System.out::println);

	List<List<List<String>>> l2 = Arrays.asList(Arrays.asList(Arrays.asList("pineapple", "grape")));

	l2.stream().flatMap(li2 -> li2.stream()).flatMap(li3 -> li3.stream()).forEach(System.out::println);
    }
}
package tryAny.stream;

import java.util.HashMap;
import java.util.Map;

public class StreamTest6 {
    public static void main(String[] args) {
	Map<String, Integer> m = new HashMap<>();
	m.put("A", 1);
	m.merge("A", 2, (v1, v2) -> v1 * v2);
	m.merge("b", 1, (v1, v2) -> v1 * v2);

	System.out.println(m);
	// {A=2, b=1}

    }
}
package tryAny.stream;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamTest8 {
    public static void main(String[] args) {
	/**
	 * Collectors.toList()The Collector object created by</br>
	 *Accumulate input elements in List.
	 */
	List<String> l = Stream.of("paper", "book", "photo").collect(Collectors.toList());

	l.stream().forEach(System.out::println);

	// Collector<Integer,Map<String,Integer>,Map<String,List<Integer>>>
	// collector
	// = Collectors.groupingBy(Integer;]

	//Group by number of characters
	Map<Integer, List<String>> map = l.stream().collect(Collectors.groupingBy(e -> e.length()));
	map.forEach((v1, v2) -> System.out.println(v1 + ":" + v2));
	/**
	 * 4:[book]</br>
	 * 5:[paper, photo]
	 */

	//Group after the acronym
	Map<Character, List<String>> map2 = l.stream().collect(Collectors.groupingBy(e -> e.charAt(0)));
	map2.forEach((v1, v2) -> System.out.println(v1 + ":" + v2));
    }
}
package tryAny.lambda;

import java.util.function.IntFunction;
import java.util.function.ToIntFunction;

public class LambdaTest7 {
    public static void main(String[] args) {
        //Returns the int taken as an argument as a character
        IntFunction<String> intFunc = String::valueOf;

        //Returns the number of String characters taken as an argument
        ToIntFunction<String> toIntFunc = String::length;

        System.out.println(intFunc.apply(11));
        System.out.println(toIntFunc.applyAsInt("apple"));
    }
}

Chapter 5 Exceptions and Assertions

package tryAny.exception;

public class ExceptionTest1 {
    public static void main(String[] args) {
	try {
	    x();
	} catch (Throwable e) {
	    while (e != null) {
		System.out.println(e.getMessage());
		e = e.getCause();
	    }
	    /**
	     * from x</br>
	     * from y</br>
	     * from z
	     */
	}
    }

    static void x() throws Exception {
	try {
	    y();
	} catch (Exception e) {
	    throw new Exception("from x", e);
	}
    }

    static void y() throws Exception {
	try {
	    z();
	} catch (Exception e) {
	    throw new Exception("from y", e);
	}
    }

    static void z() throws Exception {
	throw new Exception("from z");
    }
}
package tryAny.exception;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class ExceptionTest2 {
    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new FileReader("src/main/java/tryAny/stream/sample.txt"));
	    int a = Integer.parseInt("a");
	} catch (IOException | NumberFormatException e) {
	    System.out.println(e);
	}
    }
}
package tryAny.exception;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class ExceptionTest3 {
    public static void main(String[] args) {
	try (FileReader in = new FileReader("src/main/java/tryAny/stream/sample.txt");
		FileWriter out = new FileWriter("src/main/java/tryAny/exception/sample.txt");
		AutoCloseTest act = new AutoCloseTest();
		/** AutoCloseTest2 act2 = new AutoCloseTest2();← Not implemented because AutoCloseable is not implemented**/ ) {
	    //AutoCloseTest close is executed.
	} catch (IOException e) {

	}
    }
}

class AutoCloseTest implements AutoCloseable {
    @Override
    public void close() {
	System.out.println("AutoCloseTest is closed.");
    }
}

class AutoCloseTest2 {
    public void close() {
	System.out.println("AutoCloseTest is closed.");
    }
}
package tryAny.exception;

public class ExceptionTest4 {
    public static void main(String[] args) {
	int x = 1;

	assert (x == 2) : "Send an Error Message!";
	/**
	 *In the VM argument-When I put ea, I get the following error.
	 *
	 * Exception in thread "main" java.lang.AssertionError:Send an Error Message!
	 * at tryAny.exception.ExceptionTest4.main(ExceptionTest4.java:7)
	 *
	 */
    }
}

Chapter 6 Date / Time API

package tryAny.dateTime;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;

public class DateTest1 {
    public static void main(String[] args) {
	LocalDateTime now = LocalDateTime.now();
	LocalDate ld = LocalDate.of(2018, Month.JANUARY, 1);

	System.out.println(now + " " + ld);
    }
}
package tryAny.dateTime;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

public class DateTest2 {
    public static void main(String[] args) {
	LocalDate ld1 = LocalDate.now();
	LocalDate ld2 = ChronoUnit.YEARS.addTo(ld1, -1);
	long l = ChronoUnit.DAYS.between(ld1, ld2);

	System.out.println(ld1);//now
	System.out.println(ld2);//One year ago
	System.out.println(l);//If you do not consider leap years, etc.-365
    }
}
package tryAny.dateTime;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.temporal.ChronoUnit;

public class DateTest3 {
    public static void main(String[] args) {
	LocalDateTime ldt1 = LocalDateTime.now();
	LocalDateTime ldt2 = ChronoUnit.DAYS.addTo(ldt1, 31);

	Duration d = Duration.between(ldt1, ldt2);
	Period p = Period.between(ldt1.toLocalDate(), ldt2.toLocalDate());

	System.out.println(d + " " + p);// PT744H P1M
    }
}
package tryAny.dateTime;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;

public class DateTest4 {
    public static void main(String[] args) {
	DateTimeFormatter dtf1 = DateTimeFormatter.BASIC_ISO_DATE;
	DateTimeFormatter dtf2 = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);

	System.out.println(dtf1.format(LocalDate.now()));
	System.out.println(dtf2.format(LocalDateTime.now()));

	//Create your own format
	DateTimeFormatter dtf3 = DateTimeFormatter.ofPattern("yyyy★MM★dd");
	System.out.println(dtf3.format(LocalDate.now()));
    }
}

Chapter 7 Java / IO

package tryAny.io;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

public class IOTest1 {
    public static void main(String[] args) {
	try (PrintWriter pw = new PrintWriter("out.txt")) {
	    pw.println("Hello world");
	    //BufferedWriter cannot output primitive types such as boolean and double as they are.
	    pw.println(true);
	    pw.println(0.4);
	} catch (FileNotFoundException e) {
	    System.out.println(e);
	}
    }
}
package tryAny.io;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class IOTest3 {
    public static void main(String[] args) throws IOException {
	//Stores serialized data.
	try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("iotest3.ser"))) {
	    String test = "iotest3";
	    oos.writeObject(test);//This is iotest3.You can ser.
	    oos.writeInt(111);
	} catch (IOException e) {
	    throw new IOException(e);
	}

	//Get the serialized data and expand it to memory.
	try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("iotest3.ser"))) {
	    System.out.println(ois.readObject());
	    System.out.println(ois.readInt());
	} catch (ClassNotFoundException | IOException e) {
	    throw new IOException(e);
	}
    }
}
package tryAny.io;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;

public class IOTest5 {
    public static void main(String[] args) throws IOException {
	Path p = Paths.get("out.txt");

	//Creation date and time
	System.out.println((FileTime) Files.getAttribute(p, "creationTime"));

	//size
	System.out.println((long) Files.getAttribute(p, "size"));

	//Whether it is a symbolic link
	System.out.println((boolean) Files.getAttribute(p, "isSymbolicLink"));
    }
}
package tryAny.io;

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

public class IOTest6 {
    public static void main(String[] args) throws IOException {
	Path p = Paths.get("src");

	//When a file appears, output it as standard.
	Files.walkFileTree(p, new SimpleFileVisitor<Path>() {
	    @Override
	    public FileVisitResult visitFile(Path path, BasicFileAttributes bfa) throws IOException {
		System.out.println(path);
		return FileVisitResult.CONTINUE;
	    }
	});

	//Output only the directory.
	Files.walk(p).filter(path -> {
	    try {
		return (boolean) Files.getAttribute(path, "isDirectory");
	    } catch (IOException e) {
		System.out.println(e);
		return false;
	    }
	}).forEach(System.out::println);
    }
}

Chapter 8 Concurrency

package tryAny.concurrentUtility;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;

public class ConcurrentTest5 {
    public static void main(String[] args) throws InterruptedException, ExecutionException {

	ExecutorService es = Executors.newFixedThreadPool(8);
	MyAtomCounter mac = new MyAtomCounter();

	Future<?> ret1 = es.submit(new MyAtomWorker(mac));
	Future<?> ret2 = es.submit(new MyAtomWorker(mac));

	ret1.get();
	ret2.get();
	es.shutdown();

	//It will definitely be 200,000.
	mac.show();

    }
}

class MyAtomCounter {
    private AtomicInteger count = new AtomicInteger();

    public void increment() {
	count.incrementAndGet();
    }

    public void show() {
	System.out.println("For AtomicInteger:" + count);
    }
}

class MyAtomWorker implements Runnable {
    private static final int NUM_LOOP = 100000;
    private final MyAtomCounter counter;

    MyAtomWorker(MyAtomCounter counter) {
	this.counter = counter;
    }

    @Override
    public void run() {
	for (int i = 0; i < NUM_LOOP; i++) {
	    counter.increment();
	}
    }
}
package tryAny.concurrentUtility;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class ConcurrentTest9 {
    public static void main(String[] args) {

        Runnable runner = new Runner();
        CyclicBarrier barrier = new CyclicBarrier(3, runner);

        List<Worker> workers = new ArrayList<Worker>();
        for (int i = 0; i < 3; i++) {
            workers.add(new Worker(barrier));
        }

        workers.stream().parallel().forEach(Worker::run);
        /**
         * 1<br>
         * 2<br>
         * 3<br>
         * All threads have run.
         *
         * 1,2,Part 3 may not be the case. 1,2,It's like 1.
         */
    }
}

class Runner implements Runnable {

    @Override
    public void run() {
        System.out.println("All threads have run.");
    }
}

class Worker extends Thread {
    private CyclicBarrier barrier;

    private static int count;

    public Worker(CyclicBarrier barrier) {
        this.barrier = barrier;
    }

    @Override
    public void run() {
        try {
            System.out.println(++count);
            barrier.await();
        } catch (InterruptedException | BrokenBarrierException e) {
            e.printStackTrace();
        }
    }
}
package tryAny.concurrentUtility;

import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

//Continues to generate random values every second.
public class ConcurrentTest6 {
    public static void main(String[] args) {
	ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);

	ScheduledFuture<?> sf = stpe.scheduleAtFixedRate(new Runnable() {
	    @Override
	    public void run() {
		System.out.println(Math.random());
	    }
	}, 1000, 1000, TimeUnit.MILLISECONDS);

	while (true) {
	    if (sf.isCancelled() || sf.isDone()) {
		stpe.shutdown();
		break;
	    }
	}
    }
}
package tryAny.concurrentUtility;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveAction;

public class ConcurrentTest7 {
    public static void main(String[] args) throws InterruptedException {
	ForkJoinPool jfp = new ForkJoinPool();
	jfp.execute(new MyAction());
	System.out.println("①");
	Thread.sleep(3000);
	System.out.println("②");
	/**
	 * ①</br>
	 * ③</br>
	 * ②
	 */

	jfp.invoke(new MyAction());
	System.out.println("①");
	Thread.sleep(3000);
	System.out.println("②");
	/**
	 * ③</br>
	 * ①</br>
	 * ②
	 */
    }
}

class MyAction extends RecursiveAction {
    @Override
    protected void compute() {
	try {
	    Thread.sleep(2000);
	} catch (InterruptedException e) {
	    e.printStackTrace();
	}

	System.out.println("③");
    }
}

Chapter 9 JDBC Database Application

package tryAny.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcTest1 {
    public static void main(String[] args) {
	try (Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "test", "test");
		Statement stmt = c.createStatement()) {
	    ResultSet rs = stmt.executeQuery("SELECT * FROM personal;");
	    if (rs.absolute(4)) {
		System.out.println(rs.getString(2));
	    }

	    if (stmt.execute("SELECT * from personal")) {
		ResultSet rs2 = stmt.getResultSet();
		if (rs2.next()) {
		    System.out.println(rs2.getInt(1));
		}
	    }

	    System.out.println(stmt.executeUpdate("insert into personal values(6,'ccc','dddd')"));
	} catch (SQLException e) {
	    e.printStackTrace();
	}

    }
}
Class.forName("com.mysql.jdbc.Driver");

Chapter 10 Localization

package tryAny.locale;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class LocaleTest1 {
    public static void main(String[] args) {

	try (InputStream is = new FileInputStream("test.properties");
		InputStream is2 = new FileInputStream("test2.properties")) {
	    Properties p = new Properties();
	    p.load(is);
	    p.list(System.out);
	    System.out.println("★" + p.getProperty("fruit") + "★");

	    //The load here is not an overwrite, but an addition.
	    p.loadFromXML(is2);
	    p.forEach((k, v) -> System.out.println(k + "=" + v));
	    System.out.println("★" + p.getProperty("hoge") + "★");

	    /**
	     * -- listing properties --</br>
	     * fruit=apple</br>
	     * vegitable=carot</br>
	     * ★apple★</br>
	     * vegitable=carot</br>
	     * hoge=Hoge</br>
	     * fuga=Fuga</br>
	     * fruit=apple</br>
	     * piyo=Piyo</br>
	     *★ Hoge ★</br>
	     *
	     */
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }
}
package tryAny.locale;

import java.util.Locale;
import java.util.ResourceBundle;

public class LocaleTest2 {
    public static void main(String[] args) {
	// test_ja_JP.fruit in properties=banana
	ResourceBundle rb1 = ResourceBundle.getBundle("test");
	System.out.println(rb1.getString("fruit"));// banana

	// test_en_US.fruit in properties=apple
	ResourceBundle rb2 = ResourceBundle.getBundle("test", Locale.US);
	System.out.println(rb2.getString("fruit"));// apple
    }
}
Locale.Builder b = new Locale.Builder();
b.setLanguage("cat");
b.setRegion("ES");
Locale l = b.build();

Miscellaneous feelings after taking the exam

Recommended Posts

What I learned with Java Gold
What I learned with Java Silver
What i learned
What I learned from Java monetary calculation
What I learned ② ~ Mock ~
What I learned ① ~ DJUnit ~
What I learned from doing Java work with Visual Studio Code
What I learned in Java (Part 2) What are variables?
What I researched about Java 8
I started Java Gold (Chapter 1-1)
What I researched about Java 6
What I researched about Java 9
I took Java SE8 Gold.
What I researched about Java 7
What I learned about Kotlin
What I researched about Java 5
What I learned in Java (Part 3) Instruction execution statement
What I learned when building a server in Java
Java lambda expressions learned with Comparator
What I learned from studying Rails
What I learned in Java (Part 4) Conditional branching and repetition
I tried UDP communication with Java
What is thread safe (with Java)
What you learned when you acquired Java SE 8 Silver and Gold
What I researched about Java learning
What I have learned in Java (Part 1) Java development flow and overview
[Note] What I learned in half a year from inexperienced (Java)
[Note] What I learned in half a year from inexperienced (Java) (3)
What I often do when I have trouble naming with Java (etc.)
Take what you've learned about Java reflection
Learn Java with "So What" [For beginners]
What I learned through the swift teacher
I tried using OpenCV with Java + Tomcat
What is java
What is Java <>?
What is Java
I tried to make Basic authentication with Java
Summary of what I learned about Spring Boot
[Java] What should I use for writing files?
I want to use java8 forEach with index
What I did when I converted java to Kotlin
I tried to break a block with java (1)
Summary of what I learned in Spring Batch
Install java with Homebrew
I tried what I wanted to try with Stream softly.
I tried to implement TCP / IP + BIO with JAVA
Change seats with java
Install Java with Ansible
I first touched Java ③
I first touched Java ④
Comfortable download with JAVA
I will write what I learned about docker anyway (second)
Why can I develop Java with Visual Studio Code?
Switch java with direnv
I dealt with Azure Functions not working in Java
I tried OCR processing a PDF file with Java
I played with Refinements
Java Gold Countermeasures: Format
I tried to implement Stalin sort with Java Collector
Download Java with Ansible
I want to transition screens with kotlin and java!