About 36,900,000 results
Open links in new tab
  1. Java Strings - GeeksforGeeks

    May 6, 2025 · There are two ways to create a string in Java: Syntax: <String_Type> <string_variable> = "<sequence_of_string>"; 1. String literal (Static Memory) To make Java …

  2. Java: how to initialize String []? - Stack Overflow

    Apr 1, 2010 · String[] string=new String[60]; System.out.println(string.length); it is initialization and getting the STRING LENGTH code in very simple way for beginners

  3. Java - Create a new String instance with specified length and …

    Nov 26, 2009 · Sometimes you want to create a new string with a specified length, and with a default character filling the entire string. ie, it would be cool if you could do new String(10, '*') …

  4. String Initialization in Java - Baeldung

    Jan 8, 2024 · First of all, we should remember how String s are created in Java. We can use the new keyword or the literal syntax: String usingNew = new String ("baeldung"); String …

  5. Which is best way to create String in java - Stack Overflow

    Mar 21, 2020 · When you have to create a new string from byte array, you have to use new String(byte[] buf). Buy the way. To move string to String Pool you can use String.intern(): 1=>. …

  6. String Class in Java - GeeksforGeeks

    May 1, 2025 · There are two ways to create string in Java: 1. Using String literal. String s = “GeeksforGeeks”; 2. Using new keyword. String s = new String (“GeeksforGeeks”); Construct …

  7. How to Initialize and Compare Strings in Java? - GeeksforGeeks

    Jun 19, 2024 · Immutability creates two general ways of initialization with strings in Java using the String Pool. This article will cover those methods, including examples and explanations. …

  8. Java Strings - How to Declare String in Java With Examples

    Feb 13, 2025 · There are two ways to create a String object: By string literal : Java String literal is created by using double quotes. For Example: String s=“Welcome”; By new keyword : Java …

  9. A Comprehensive Guide to Java String Initialization

    Using the 'new' keyword creates a new String object, which is useful when you want a guaranteed reference to a separate String instance. Sometimes you may want to initialize an empty String …

  10. JavaString Class and Methods with examples - BeginnersBook

    Oct 25, 2022 · To create a new instance of a string, we use new keyword. When we create a string using new keyword, it gets created in heap memory rather than string constant pool as …

Refresh