Example usage for java.lang String valueOf

List of usage examples for java.lang String valueOf

Introduction

In this page you can find the example usage for java.lang String valueOf.

Prototype

public static String valueOf(double d) 

Source Link

Document

Returns the string representation of the double argument.

Usage

From source file:Main.java

public static void main(String[] args) {
    String s1 = String.valueOf('C'); // s1 has "C"
    String s2 = String.valueOf("10"); // s2 has "10"
    String s3 = String.valueOf(true); // s3 has "true"
    String s4 = String.valueOf(2014); // s4 has "2014"
}

From source file:Main.java

public static void main(String[] args) {
    boolean b = false;
    char c = 'c';
    int i = 100;/*w  w  w .  java 2s  .  c  om*/
    long l = 100000;
    float f = 3.4f;
    double d = 500.99;

    System.out.println("b = " + String.valueOf(b));
    System.out.println("c = " + String.valueOf(c));
    System.out.println("i = " + String.valueOf(i));
    System.out.println("l = " + String.valueOf(l));
    System.out.println("f = " + String.valueOf(f));
    System.out.println("d = " + String.valueOf(d));
}

From source file:Main.java

public static void main(String[] argv) {
    List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7);

    System.out//w  w  w  .j ava 2 s .  c o m
            .println(numbers.stream().map(number -> String.valueOf(number)).collect(Collectors.joining(", ")));
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path start = Paths.get("c:/Java_Dev/");
    int maxDepth = 5;
    Files.find(start, maxDepth, (path, attr) -> String.valueOf(path).endsWith("xls")).sorted()
            .forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path start = Paths.get("c:/Java_Dev/run.bat");
    int maxDepth = 5;
    long fileCount = Files.walk(start, maxDepth).filter(path -> String.valueOf(path).endsWith("xls")).count();
    System.out.format("XLS files found: %s", fileCount);
}

From source file:Main.java

public static void main(String[] args) {
    String input = "This is a sentence";
    char[] charinput = input.toCharArray();
    Stack<String> stack = new Stack<String>();
    for (int i = input.length() - 1; i >= 0; i--) {
        stack.push(String.valueOf(charinput[i]));
    }/*  w w w.j ava 2s .com*/
    StringBuilder StackPush = new StringBuilder();
    for (int i = 0; i < stack.size(); i++) {
        StackPush.append(stack.get(i));
    }
    System.out.println(StackPush.toString());
}

From source file:Main.java

public static void main(String[] args) {
    Console console = System.console();
    String username = console.readLine("Username: ");
    char[] password = console.readPassword("Password: ");

    if (username.equals("admin") && String.valueOf(password).equals("secret")) {
        console.printf("Welcome to Java Application %1$s.\n", username);

        Arrays.fill(password, ' ');
    } else {// w  w w. j a  va  2  s.co m
        console.printf("Invalid username or password.\n");
    }
}

From source file:Main.java

public static void main(String[] args) {
    List<Person> list = new ArrayList<Person>();
    for (int i = 10; i > 0; i--) {
        list.add(new Person(i, "name" + String.valueOf(i), new Date()));
    }/*ww w.  ja  va 2  s . co  m*/
    System.out.println(list);
    Collections.sort(list);
    System.out.println(list);
}

From source file:Main.java

public static void main(String args[]) {
    int i = 1;// w  w  w . j  a  va  2 s. c om
    float f = 1.0f;
    long l = 1;
    double d = 1.0d;
    char c = 'a';
    boolean b = true;

    Object o = new String("Hello World");
    /* convert int to String */
    System.out.println(String.valueOf(i));
    /* convert float to String */
    System.out.println(String.valueOf(f));
    /* convert long to String */
    System.out.println(String.valueOf(l));
    /* convert double to String */
    System.out.println(String.valueOf(d));
    /* convert char to String */
    System.out.println(String.valueOf(c));
    /* convert boolean to String */
    System.out.println(String.valueOf(b));
    /* convert Object to String */
    System.out.println(String.valueOf(o));
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel(new GridLayout(10, 10, 10, 10));

    for (int i = 0; i < 100; i++) {
        panel.add(new JButton(String.valueOf(i)));
    }/*from w w  w.ja  va2 s  .  c  o m*/

    frame.add(panel);

    frame.setSize(600, 600);
    frame.setVisible(true);
}