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 do you mean by jjs in java8?

563


How are java objects passed to a method and what are native methods?

604


What is variable declaration and definition?

548


What is the java virtual machine?

591


In which language java is written?

542






What is abstraction in java?

621


What is the meaning of course?

589


What is considered an anti pattern?

531


Why java applets are more useful for intranets as compared to internet?

582


Does a function need a return?

537


what is meant by HQL?

647


Can static methods be inherited?

537


What is the default execution method in java?

626


What is tcp ip in java?

592


Is vector synchronized in java?

561