string related

string related

As with any other object, you can create String objects by using the new keyword and a constructor. The String class has thirteen constructors that allow you to provide the initial value of the string using different sources, such as an array of characters:

char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.'};

String helloString = new String(helloArray);

System.out.println(helloString);

The last line of this code snippet displays hello.

Could u plz explain the two statements in bold above and what these two statements mean and why is it that System.out.println(helloString) would only display hello but not helloArray.

View Answers

May 23, 2011 at 12:57 PM

You have declared a character array named helloArray and initialize its values with characters h,e,l,l,o and .

The statement String helloString = new String(helloArray); store the elements of character array in the form of string. Now the array elements get connverted into string and System.out.println(helloString) prints the string hello.









Related Tutorials/Questions & Answers:
string related
string related  As with any other object, you can create String objects by using the new keyword and a constructor. The String class has thirteen constructors that allow you to provide the initial value of the string using
string related question
string related question  *q.1>how i dispaly the reference of string variableS ? eg:-String s1="my name"; Sring s2="your name"; here what is address of variable s1 and s2
Advertisements
java fundamental question related to string
java fundamental question related to string  public class Myclass { Public static void main(String args[]) { String s=â??helloâ??; StringBuffer sb=new StringBuffer(s); Sb.reverse(); If(s==sb) system.out.println(â??aâ
PHP related - how to explot a string with commas and store into two different variables?
PHP related - how to explot a string with commas and store into two different variables?  Hi, I have a string and is like this '[tubelist 123456,54321,56789,98765]'. I would like to extract the first value after the tubelist
STRING.....
STRING.....  plzz sent me d code for counting vowels in a string... gui programme
string
string   difference detween "public static void main (String[] args) " and "public static void main (String args[])" in java but it executes both... "String args[]" can mean a "string array called args which is an array
StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable
string
string  String helloString = new String(helloArray); System.out.println(helloString); i am unable to understand this. could u plz explain
string
string  a java program using string function to input any string... ArrangeStringAlphabetically { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string
String
String  how to add spaces with string functions.?   Hi... { public static String addSpaceToRight(String s, int n) { return String.format("%1$-" + n + "s", s); } public static String addSpaceToLeft(String s, int n
String
characters in string?   import java.util.*; class RemoveDuplicateCharatcersFromString { public static String removeDuplicates(String s... < s.length(); i++) { String st = s.substring(i, i + 1
String
String  write down the code of remove any character from a given string without using any string function   please give me the code of remove any given character from a given string without using function
string
string  a java program to input a string and display the string...*; import java.io.*; public class FirstLetter{ public static String capitalizeFirstLetter( String str ) { final StringTokenizer st = new StringTokenizer( str
string
*; class ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String: "); String st=input.nextLine(); String str[]=st.split
string
string   just i want to a program in a short form to the given string in buffered reader for example input string: Suresh Chandra Gupta output: S. C...; public class StringTest { public static void main(String [] args
string
string  write a program to accept the string and store the reverse stream into another array and print
string
string  java prgm to find total occurence of a given string pattern in a sentence
string
string  java prgm to find total occurence of a given string pattern in a sentence
String
String  write a program using string it should replace 'c'char to integer number as 1 in whole source
String
String  How to Convert sunnapu gopal to Sunnapu Gopal in java using String
String
String  how to print in between numbers if the question "String s = "1,2,3,4,5,6,8,-25"" out must be 1 2,3,4,5,6,7,8,9,10,upto25
string
and also displaying that contain word? Like I want to find "a" in the string... and a character. It then count the occurrence of that character in the string and display... String_Example { public static void main(String[] args
related to database
related to database  how to override existing values in table? when user enters his updated data through query
string
string  program for String reverse and replace in c,c++,java e.g.Input:10,20,hello output:hello;20;10   Hi Friend, Try the following java...(String[] args) { String array[]=new String[5]; Scanner input
string
string  a java program using string function that computes your initials from your full name and display them   Please visit the following links: http://www.roseindia.net/tutorial/java/core/printInitials.html
Related to Histogram
Related to Histogram  hi this is srinivasrao. In my project i have to display using chart for that i want to use histogram. k chart displayed but the values given by me is not related display chart so please give the code if u
string
string  a java program using string function and access modifiers to automate the insurance company which will have to manage the information about policy holders Data Members: 1)Policy No 2)Name of policy holder 3)Address 4
related to java
related to java  what is mean of }); in java.i know that } is used to close a block of statement,) is used to close a statement and ";"is used after close a statement but i can not usderstood the use of }); together in a java
Related Questions
Related Questions  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Related Questions... "Related Questions". Also tell me which is the good training courses
Related to Project
Related to Project  how speech to text project can be make in java? Please tell me the coding part therapeutically i know i have to use java speech api which offer two technology 1. speech recognization 2. speech syenthesis
Related to XML
Related to XML  I have made a web application which send the SMS, i have provided the url in which i have to save the msg and the number's(to whom the message to be send).After fetching the message and numbers i was keeping
Related to XML
Related to XML  I have made a web application which send the SMS, i have provided the url in which i have to save the msg and the number's(to whom the message to be send).After fetching the message and numbers i was keeping
java question related to objects
java question related to objects  what is the output of the following code? public class objComp { Public static void main(String args[]) { Int result = 0; objComp oc= new objComp(); object o = oc; if( o==oc) result =1; if(o
ModuleNotFoundError: No module named 'related'
ModuleNotFoundError: No module named 'related'  Hi, My Python... 'related' How to remove the ModuleNotFoundError: No module named 'related... to install padas library. You can install related python with following command
Data base related question
Data base related question  sir my table has only one element...=DriverManager.getConnection("jdbc:odbc:oldp"); stmt2=con2.createStatement(); String... static void main(String args[]) { raja p=new raja(); p.k(); } } //could you
query related to awt
query related to awt  Hi, I want to know how to check a text value...){ String input=text.getText(); Pattern p = Pattern.compile("[A-Z...(""); } } }); } public static void main(String[] args){ new CheckTextFieldValue
Dumps related to weblogic certification
Dumps related to weblogic certification   I want to perform the weblogic certification exam code 1z0-110. Can anybody please provide me the dumps related to 1z0-110 Thanks in advance
JDBC ODBC related problem
JDBC ODBC related problem  i WANT HELP RELATED TO JDBC CONNECTIVITY...(); String course[] = {"Navakal","SandhyaKal","Pudhari","MidDay","Inqlab","BusinessLine...()); ERROR{ String str = (String
JDBC related Problem - JDBC
JDBC related Problem  Hey plz check out the following code .... import java.sql.*; class DatabaseStore { public static void main(String [] args) { String ds = "sch"; // the datasource name String dbUrl
Java and jvm related question
Java and jvm related question  What is difference between java data types and jvm data types
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
Question related to Hibernate
Question related to Hibernate  Why do we use Set in child class in 1:many hibernate ,why can't we use Directly HashSet
Server Related exception
Server Related exception  How will write code to handle serverside exceptions in our projects.Earlier we dont know which exception the code will throw
liferay related query
liferay related query  can you suggest me how to get all the session ids of different users logged in to liferay
Java Related Question
Java Related Question  hi, Why java doesn't has primitive type as an object,whats an eligibility to have a primitive type as an object by the languages
code related problem
code related problem  this code is compiling but not running please... { public void actionPerformed(ActionEvent e) { if(e.getSource()==button1) { String...(String[] args) throws Exception { Mybutton11 m = new Mybutton11
JDBC related query
JDBC related query  How to merge two resultset of two different queries, wherein both the resultset(after query execution)gives an integer value as its column
project related question
project related question  1- how to insert a date through hibernate 2- how to insert exact time ,date separetly in the data base for current time date
problem related to onSubmit() method
problem related to onSubmit() method  Hello, I am developing application.when i submit form at that time formBacking() method is call...Instead of that onSubmit() should have to call .... please help me

Ads