how we can write the string concatenation program in java.

Answer Posted / ashwini kumar vatsa

In java first all the integer or float etc declared are
converted into string so when we write
System.out.println("the name is"+x);where x is any primitive
type then first x is converted into string then it
concatenates with the other string so for concatenations
with other string we must have +operator.
class xyz{
static int x;
public static void main(String args[]){
xyz yz=new xyz();
yz.x=10;
System.out.println("the output is"+x);//here concat done
}
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the largest data type in java?

711


State the main difference between c++ and java?

777


Why is boolean important?

783


Can we use return in constructor?

674


what do you understand by synchronization? : Java thread

773


What is jit compiler in java?

780


What is the benefit of inner classes in java?

832


What is console based application in java?

772


What is consumer in java?

702


Can substring create new object?

768


Define how destructors are defined in java?

757


Explain 5 features introduced in jdk 1.7?

795


Explain method overloading?

744


Why string is a class?

718


What is user defined exception in Java?

825