Thursday, December 24, 2015

String Concatenation with other data type

String Concatenation with other data type:

package stringdemo;


public class StringS {
    public static void main(String[] args) {
        String s="nine:"+4+4;
        System.out.println(s);
    }
}

Here output will be like 
nine:44.
   rather than
nine:8

To get 2nd type of output we must change the 
String s="nine:"+(4+4);

This will generate the output as:
nine:8

Related Posts:

  • equals() Versus ==equals() Versus == We should be clear that equals() method and == operator perform two different operations.The equals() method compares the characte… Read More
  • String Concatenation with other data typeString Concatenation with other data type: package stringdemo; public class StringS {     public static void main(String[] args) {  … Read More
  • The String Constructor:The String Constructor: //Construct one String from other class MakeString{ public Static void main(String[] args){ Char c[]={'d','o','g'}; String s… Read More
  • equals() and equalsIgnoreCase()String Comparision: The String class includes many methods that compares Strings or Substrings within strings. equals() and equalsIgnoreCase() pac… Read More
  • String Concatenation:String Con:catenation Here is a small java program to demonstrate String Concatenation: package stringdemo; public class StringConcat {   &nbs… Read More

0 comments:

Post a Comment