- 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
Creating String Object from certain part of a character Array in Java
Here is our character array.
char[] ch = { 'T', 'E', 'S', 'T', 'I', 'N', 'G'};
Create string object from some part of a string using the following String constructor. Through this we are fetching substring “IN” from the character array.
String str = new String(ch, 4, 2);
Example
public class Demo { public static void main(String[] args) { char[] ch = { 'T', 'E', 'S', 'T', 'I', 'N', 'G'}; String str = new String(ch, 4, 2); System.out.println(str); } }
Output
IN
- Related Articles
- Creating String Object from Character Array in Java
- Creating a string from a subset of the array elements in Java
- Java Program to create Character Array from String Objects
- How to order by certain part of a string in MySQL?
- Remove a character from a Java StringBuffer object
- Querying from part of object in an array with MongoDB
- Get part of a string based on a character in MySQL?
- Difference between String and Character array in Java.
- Java program to convert a character array to string
- How to extract certain substring from a string using Java?
- Append a single character to a string or char array in java?
- Does JavaScript have a method to replace part of a string without creating a new string?
- How to get a part of string after a specified character in JavaScript?
- Creating a JavaScript Object from Single Array and Defining the Key Value?
- How to remove the last character from a string in Java?

Advertisements