
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create String Object from Part of 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
Advertisements