About 629,000 results
Open links in new tab
  1. Java array declaration in multiple lines. - Stack Overflow

    Feb 6, 2013 · Yes, you can put your strings on multiple lines. However, use double-quotes to surround your String literals: public String[] songList = {"Stadium Arcadium", "Make You Feel Better", "Under The Bridge", "Wet Sand", "Californication", …

  2. java - printing an array in multiple lines - Stack Overflow

    Mar 4, 2014 · You can use System.out.print() to print a value without a newline following it. This will allow you to print multiple things on the same line. I have a little bit of code but I don't know where to go from here:

  3. java - Any way to declare an array in-line? - Stack Overflow

    Feb 28, 2016 · As Draemon says, the closest that Java comes to inline arrays is new String[]{"blah", "hey", "yo"} however there is a neat trick that allows you to do something like array("blah", "hey", "yo") with the type automatically inferred.

  4. How to Extract a Specific Line from a Multi-Line String in Java?

    Feb 14, 2024 · This Java program extracts a specific line from a multi-line string by splitting the string into an array of lines. Then it retrieves the line at the specified index. It uses the split() method to separate the multi-line string into individual lines based on the newline character (\n).

  5. Java Multi-line String - Baeldung

    Jan 8, 2024 · In this tutorial, we'll learn how to declare multiline strings in Java. Now that Java 15 is out, we can use the new native feature called Text Blocks. We'll also review other methods if we can't use this feature.

  6. Java String Class lines() Method with Examples - GeeksforGeeks

    Feb 3, 2022 · lines() method is a static method which returns out stream of lines extracted from a given multi-line string, separated by line terminators which are as follows:

  7. Java Array (With Examples) - Programiz

    In this tutorial, we will learn to work with Java arrays. We will learn to declare, initialize, and access array elements with the help of examples. An array is a collection of similar data types.

  8. Java Multi-Dimensional Arrays - GeeksforGeeks

    Apr 23, 2025 · Example: This Java program shows how to create and use a multidimensional array. Syntax for Multi-Dimensional Array. data_type[1st dimension] [2nd dimension] [].. [Nth dimension] array_name = new data_type[size1] [size2]…. [sizeN]; Parameters: data_type: Type of data to be stored in the array. For example: int, char, etc.

  9. java - Multi-line string to array - Stack Overflow

    Using Guava, you can produce a list of lists in a one-liner -- applying a Function for each row that takes as input a String containing whitespace-separated columns and outputting the columns of the row as List<String>. If you prefer a 2d array of strings, then you need some more code: String content = new String(Files.readAllBytes(Paths.

  10. Java Multiline String (with Examples) - HowToDoInJava

    Multiline strings allow the creation of string literals that span several lines of source code. Writing multi-line strings in Java can be approached differently depending on the version of Java you are using. For example, Java 15 (and later) has native support for multiline strings via Text Blocks.

  11. Some results have been removed
Refresh