Example usage for java.util Arrays toString

List of usage examples for java.util Arrays toString

Introduction

In this page you can find the example usage for java.util Arrays toString.

Prototype

public static String toString(Object[] a) 

Source Link

Document

Returns a string representation of the contents of the specified array.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);//from w  ww.  ja va2s .c o  m
    DocumentBuilder builder;
    Document doc = null;
    builder = factory.newDocumentBuilder();
    doc = builder.parse("employees.xml");
    // Create XPathFactory object
    XPathFactory xpathFactory = XPathFactory.newInstance();
    // Create XPath object
    XPath xpath = xpathFactory.newXPath();
    String name = getEmployeeNameById(doc, xpath, 4);
    System.out.println("Employee Name with ID 4: " + name);

    List<String> names = getEmployeeNameWithAge(doc, xpath, 30);
    System.out.println("Employees with 'age>30' are:" + Arrays.toString(names.toArray()));

    List<String> femaleEmps = getFemaleEmployeesName(doc, xpath);
    System.out.println("Female Employees names are:" + Arrays.toString(femaleEmps.toArray()));
}

From source file:Main.java

public static void main(String[] argv) {

    JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldFile = (File) evt.getOldValue();
                File newFile = (File) evt.getNewValue();

                System.out.println(oldFile);
                System.out.println(newFile);
                System.out.println(chooser.getSelectedFile());
            } else if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File[] oldFiles = (File[]) evt.getOldValue();
                File[] newFiles = (File[]) evt.getNewValue();

                Arrays.toString(oldFiles);
                Arrays.toString(newFiles);
                File[] files = chooser.getSelectedFiles();
                Arrays.toString(files);
            }/*  www. j  av a 2s .co  m*/
        }
    });

    chooser.setVisible(true);

}

From source file:UniqueList.java

public static void main(String[] args) {
    UniqueList ul = new UniqueList();
    ul.add("Test");
    ul.add("Test");
    ul.add("Not a copy");
    ul.add("Test");
    Object[] content = ul.toObjectArray();
    System.out.println(Arrays.toString(content));
}

From source file:com.cloudera.hts.utils.math.PolyFit.java

public static void main(String[] args) {

    double[] x = { -5.0, -4.0, -3.0, -2.0, 0, 2, 3, 4 };
    double[] y = { 21, 13, 7, 3, 1, 7, 13, 21 };

    WeightedObservedPoints obs = new WeightedObservedPoints();

    // Add points here; for instance,
    int i = 0;/*  ww w.  ja  v a 2s.  c o m*/
    for (double xc : x) {

        WeightedObservedPoint point = new WeightedObservedPoint(xc, y[i], 1.0);
        obs.add(xc, y[i]);

        System.out.println(xc + " " + y[i]);

        i++;

    }

    // Instantiate a third-degree polynomial fitter.
    PolynomialCurveFitter fitter = PolynomialCurveFitter.create(2);

    // Retrieve fitted parameters (coefficients of the polynomial function).
    final double[] coeff = fitter.fit(obs.toList());

    System.out.println(Arrays.toString(coeff));

}

From source file:SpringInAction4Edition.MainApp.java

public static void main(String[] args) {

    ApplicationContext context = new AnnotationConfigApplicationContext(CDConfig.class);

    Environment env = context.getEnvironment();
    System.err.println("environment : ime : " + env.getProperty("ime"));
    System.err.println("environment : prezime : " + env.getProperty("prezime"));

    KutijaCD cd_ovi = context.getBean(KutijaCD.class);
    CDPlayer cDPlayer = context.getBean(CDPlayer.class);

    cd_ovi.getCds().stream().forEach((cd) -> {
        cd.play();/*from   w w  w .  j a v  a2s . c  o m*/
    });

    cDPlayer.getCd();
    System.err.println("BEAN DEF NAMES : " + Arrays.toString(context.getBeanDefinitionNames()));
}

From source file:jetbrains.exodus.util.ForkedProcessRunner.java

@SuppressWarnings({ "HardcodedFileSeparator" })
public static void main(String[] args) throws Exception {
    log.info("Process started. Arguments: " + Arrays.toString(args));
    if (args.length < 2) {
        exit("Arguments do not contain port number and/or class to be run. Exit.", null);
    }/*from   w w w . jav  a2 s . c o  m*/
    try {
        int port = Integer.parseInt(args[0]);
        socket = new Socket("localhost", port);
        streamer = new Streamer(socket);
    } catch (NumberFormatException e) {
        exit("Failed to parse port number: " + args[0] + ". Exit.", null);
    }
    ForkedLogic forkedLogic = null;
    try {
        Class<?> clazz = Class.forName(args[1]);
        forkedLogic = (ForkedLogic) clazz.getConstructor().newInstance();
    } catch (Exception e) {
        exit("Failed to instantiate or initialize ForkedLogic descendant", e);
    }
    // lets provide the peer with our process id
    streamer.writeString(getProcessId());
    String[] realArgs = new String[args.length - 2];
    System.arraycopy(args, 2, realArgs, 0, realArgs.length);
    forkedLogic.forked(realArgs);
}

From source file:com.example.SpannerExampleDriver.java

public static void main(String[] args) {
    System.out.println(Arrays.toString(args));
    SpringApplication.run(SpannerExampleDriver.class, args);
}

From source file:ArraysTester.java

public static void main(String[] args) {
    ArraysTester tester = new ArraysTester(50);
    int[] myArray = tester.get();

    // Compare two arrays
    int[] myOtherArray = tester.get().clone();
    if (Arrays.equals(myArray, myOtherArray)) {
        System.out.println("The two arrays are equal!");
    } else {/*from  ww w . j  av a  2 s .  c  om*/
        System.out.println("The two arrays are not equal!");
    }

    // Fill up some values
    Arrays.fill(myOtherArray, 2, 10, new Double(Math.PI).intValue());
    myArray[30] = 98;

    // Print array, as is
    System.out.println("Here's the unsorted array...");
    System.out.println(Arrays.toString(myArray));
    System.out.println();

    // Sort the array
    Arrays.sort(myArray);

    // print array, sorted
    System.out.println("Here's the sorted array...");
    System.out.println(Arrays.toString(myArray));
    System.out.println();

    // Get the index of a particular value
    int index = Arrays.binarySearch(myArray, 98);
    System.out.println("98 is located in the array at index " + index);

    String[][] ticTacToe = { { "X", "O", "O" }, { "O", "X", "X" }, { "X", "O", "X" } };
    System.out.println(Arrays.deepToString(ticTacToe));

    String[][] ticTacToe2 = { { "O", "O", "X" }, { "O", "X", "X" }, { "X", "O", "X" } };

    String[][] ticTacToe3 = { { "X", "O", "O" }, { "O", "X", "X" }, { "X", "O", "X" } };

    if (Arrays.deepEquals(ticTacToe, ticTacToe2)) {
        System.out.println("Boards 1 and 2 are equal.");
    } else {
        System.out.println("Boards 1 and 2 are not equal.");
    }

    if (Arrays.deepEquals(ticTacToe, ticTacToe3)) {
        System.out.println("Boards 1 and 3 are equal.");
    } else {
        System.out.println("Boards 1 and 3 are not equal.");
    }
}

From source file:com.kixeye.chassis.bootstrap.AppMain.java

/**
 * Main entry method.//from   w w w. jav a 2s.c om
 *
 * @param args the application arguments
 */
public static void main(String[] args) throws Exception {

    System.out.println("Starting application with arguments " + Arrays.toString(args));

    Arguments arguments = loadArguments(args);

    if (arguments == null) {
        return;
    }

    initializeLogging(arguments);

    application = new Application(arguments);

    registerShutdownHook();

    application.start();

    while (application.isRunning()) {
        //keep the main thread alive
        Thread.sleep(500);
    }
}

From source file:TopicListener.java

public static void main(String[] argv) throws Exception {
    TopicListener l = new TopicListener();
    String[] unknown = CommandLineSupport.setOptions(l, argv);
    if (unknown.length > 0) {
        System.out.println("Unknown options: " + Arrays.toString(unknown));
        System.exit(-1);//  w w w .  j a v a2s .  c  o  m
    }
    l.run();
}