Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

    public class Main {

        public static void main(String[] args) {
            ResourceBundle bundle = ResourceBundle.getBundle("MessagesBundle", Locale.UK);
            System.out.println("Message in " + Locale.UK + ": " + bundle.getString("greeting"));

            Locale.setDefault(new Locale("in", "ID"));
            bundle = ResourceBundle.getBundle("MessagesBundle");
            System.out.println("Message in " + Locale.getDefault() + ": " + bundle.getString("greeting"));
        }
    }

    Example of
    our resource
    bundle files,

            MessagesBundle_en_GB.properties

greeting=Hello, how
    are you?

MessagesBundle_in_ID.properties

greeting=Halo, apa kabar?