🌐
Oracle
docs.oracle.com › javase › tutorial › java › data › strings.html
Strings (The Java™ Tutorials > Learning the Java Language > Numbers and Strings)
The most direct way to create a string is to write: ... In this case, "Hello world!" is a string literal—a series of characters in your code that is enclosed in double quotes.
Discussions

[Java] StringBuffer is the best way to build a String from variables
Usually you actually want a StringBuilder (same api). StringBuffer adds some overhead by being synchronized. If it's isolated to a method, you don't need that sync! More on reddit.com
🌐 r/ProgrammerTIL
24
50
June 19, 2016
beginner here, how do i create a string by adding up chars?
Use StringBuilder and append one character at a time as you read them. More on reddit.com
🌐 r/javahelp
13
3
September 10, 2022
Efficient way to create a string
You could try it both ways and profile it yourself, but I would go the String Builder route More on reddit.com
🌐 r/javahelp
53
7
March 21, 2025
What is the simple way to repeat a string in Java?

You could use Apache commons-lang (which has an impressive collection of handy string utilities):

StringUtils.repeat(3, "abc")

If you're using Java 8:

Collections.nCopies(3, "abc").collect(Collectors.joining(""));
More on reddit.com
🌐 r/java
6
0
October 9, 2014
🌐
GeeksforGeeks
geeksforgeeks.org › java › strings-in-java
Java Strings - GeeksforGeeks
A string literal is created by assigning a sequence of characters directly to a String variable using double quotes. Java stores string literals in the String Constant Pool, allowing identical string values to share the same object.
Published: 2 weeks ago
🌐
W3Schools
w3schools.com › java › java_strings.asp
Java Strings
For a complete reference of String methods, go to our Java String Methods Reference. The reference contains descriptions and examples of all string methods. ... Coding fundamentals as bite-sized lessons and challenges. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
🌐
Edureka
edureka.co › blog › java-string
Java Strings - How to Declare String in Java With Examples
February 13, 2025 - By new keyword : Java String is created by using a keyword “new”. For example: String s=new String(“Welcome”); It creates two objects (in String pool and in heap) and one reference variable where the variable ‘s’ will refer to the ...
🌐
Programiz
programiz.com › java-programming › string
Java String (With Examples)
January 31, 2024 - We use double quotes to represent a string in Java. For example, // create a string String type = "Java programming";
🌐
YouTube
youtube.com › math and science
Java Tutorial - 07 - Creating and Using Strings in Java - YouTube
Get the full course at: http://www.MathTutorDVD.com In this lesson, you will learn how to create a string in Java and print the contents to the screen. Learn...
Published: February 4, 2014
Views: 98K
🌐
Igmguru
igmguru.com › home › blog › java › what is strings in java?
▷ Strings in Java: Creation, Methods, & Immutability | igmGuru
2 weeks ago - String ob3 = new String(arr, 1, 2): Creating a String from a Subsequence - This constructor builds a string from a portion of the character array, starting at index 1 and taking 2 characters ('k' and 'a'), resulting in ka. Read Also: Java Tutorial For Beginners | Learn Java Programming for Free · There are two primary ways to create Strings in Java:
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › java › java_strings.htm
Java - String Class
The most direct way to create a string is to write − ... Whenever it encounters a string literal in your code, the compiler creates a String object with its value in this case, "Hello world!".
🌐
Net Informations
net-informations.com › java › cjava › create.htm
What are different ways to create a string object in Java?
In this case, a StringBuilder object is used to construct the string "Hello World", which is then converted to a String object using the toString() method.
🌐
Great Learning
mygreatlearning.com › blog › it/software development › strings in java: creation, methods & best practices
Strings in Java: Creation, Methods & Best Practices
June 18, 2025 - Java stores String literals in the String Pool. This saves memory. If you create the same String literal twice, Java points both variables to the same object in the pool. You can also create a String object using the new keyword. This creates a new String object in the heap memory.
🌐
freeCodeCamp
freecodecamp.org › news › strings-in-java
Strings in Java
February 1, 2020 - The answer is: 2 String objects are created. Notes · String methods use zero-based indexes, except for the second argument of substring(). The String class is final - it’s methods can’t be overridden. When the String literal is found by JVM, it is added to string literal pool. String class posses a method name length(), while arrays have an attribute naming length. In java, string objects are immutable.
🌐
JavaGoal
javagoal.com › home › string in java
What is String in Java & How to Create a String - JavaGoal
November 20, 2022 - We can create a String by use of new keyword in java. String class has many constructors that take the characters in different forms and create the string. We will discuss how we can create String by use of the constructor.
🌐
Dev.java
dev.java › learn › numbers-strings › strings
Strings - Dev.java
The most direct way to create a string is to write: In this case, "Hello world!" is a string literal—a series of characters in your code that is enclosed in double quotes.
🌐
Simplilearn
simplilearn.com › home › resources › software development › java tutorial for beginners › what are java strings and how to implement them?
What are Java Strings and How To Implement Them
June 14, 2026 - What are Java strings and how do you create them? Learn all about Java strings, the methods based on Java strings, sub strings, and more with example programs.
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
TheServerSide
theserverside.com › definition › Java-string
Java string
Another way to create strings is to use the new keyword, as in the following example. ... That code will create an s1 string object and a reference variable. As noted, Java strings are immutable.
Published: November 22, 2025
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-strings
Java – String Class and Methods with examples
A string literal is a sequence of characters enclosed in double quotation marks (” “). In java, Strings can be created by assigning a String literal to a String instance:
🌐
Medium
medium.com › @AlexanderObregon › a-beginners-guide-to-java-strings-3485cba0b517
A Beginner’s Guide to Java Strings
February 23, 2024 - String original = "Java"; original = original + " Programming"; // A new string object is created here · In the above code, original initially refers to a string object containing "Java". When we append " Programming" to it, a new string object containing "Java Programming" is created and original is updated to refer to this new object.
🌐
PVPSIT
pvpsiddhartha.ac.in › dep_it › lecture notes › 2-2-23 › JAVA › unit II.pdf pdf
Java Strings:
Compares another string. It doesn't check ... String str="PVP Siddhartha Inst. of Technology"; ... So, to compare two strings use equals() method. ... Here, JVM creates a String object and stores “Welcome” in it.
🌐
Medium
medium.com › geekculture › all-about-string-in-java-51ba9e46181a
All About String in Java. Java Strings are objects that are… | by sajith dilshan | Geek Culture | Medium
February 8, 2023 - All About String in Java Java Strings are objects that are backed by a char array and are immutable. The class java.lang.String is used to create a string object. There are two ways to create a …