- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String Handling in Java
Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects.
The Java platform provides the String class to create and manipulate strings.
The most direct way to create a string is to write −
String greeting = "Hello world!";
Whenever it encounters a string literal in your code, the compiler creates a String object with its value in this case, "Hello world!'.
Example
public class StringDemo { public static void main(String args[]) { char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' }; String helloString = new String(helloArray); System.out.println( helloString ); } }
Output
hello.
- Related Articles
- Handling IllegalComponentStateException in java.
- Precision Handling in Java
- Exception Handling in C++ vs Java
- What is an Event Handling and describe the components in Event Handling in Java?
- Exception handling with method overriding in Java.
- Importance of Proper Exception Handling in Java
- Nested try blocks in Exception Handling in Java
- File Handling in Java using FileReader and FileWriter
- Comparison of Exception Handling in C++ and Java
- Handling String localization hardcoding issue in ERP like SAP, Dynamic, etc.
- How to implement JavaFX event handling using lambda in Java? \n
- Error Handling in C
- Precision Handling in Python
- Signal Handling in C++
- Handling forms in React.js

Advertisements