So I have this particular code:
import java.util.*;
class insertWordInMiddle {
public static void main(String[] args) {
String s = "Python 3.0";
String s_split[] = s.split(" ");
String a = new String(s_split[0]);
String b = new String(s_split[1]);
String c = a + " Tutorial " + b;
System.out.println(c);
}
}
I was practising and I wanted to insert a word between two words (in the form of a string). It works, however I have yet other way of doing this but cannot get why it doesn't work:
import java.util.*;
class insertWordInMiddle {
public static void main(String[] args) {
String s = "Python 3.0";
String s_split[] = s.split(" ");
String final = s_split[0]+" Tutorial "+s_split[1];
System.out.println(final);
}
}
Error:
/home/reeshabh/Desktop/java practice/insertWordInMiddle.java:14:
error: not a statement
String final = s_split[0]+" Tutorial"+s_split[1];