1. HEAD
String x,y;
String hasil;
char head;
x=txtx.getText();
y=txty.getText();
hasil = x+y;
head = hasil.charAt(0);
jTextArea.setText(""+head);
2. TAIL
String x,y;
String hasil;
char tail;
x=txtx.getText();
y=txty.getText();
hasil = x+y;
tail = hasil.charAt(hasil.length()-1);
jTextArea.setText(""+tail);
3.PREFIX
String x = txtx.getText();
String y = txty.getText();
String hasil="";
for(int i=x.length()-1; i>=0; i-- ){
for(int j=0; j<=i; j++){
hasil += ""+ x.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
hasil += "\n" ;
for(int i=y.length()-1; i>=0; i-- ){
for(int j=0; j<=i; j++){
hasil += ""+ y.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
}
4.PROPERPREFIX
String x = txtx.getText();
String y = txty.getText();
String hasil="";
for(int i=x.length()-2; i>=0; i-- ){
for(int j=0; j<=i; j++){
hasil += ""+ x.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
hasil += "\n" ;
for(int i=y.length()-2; i>=0; i-- ){
for(int j=0; j<=i; j++){
hasil += ""+ y.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
}
5. POSTFIX
String x = txtx.getText();
String y = txty.getText();
String hasil="";
for(int i=0; i<=x.length()-1; i++ ){
for(int j=i; j<=x.length()-1; j++){//////////////
hasil += ""+ x.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
hasil += "\n" ;
for(int i=0; i<=y.length()-1; i++ ){
for(int j=i; j<=y.length()-1; j++){//////////////
hasil += ""+ y.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
}
6.PROPERPOSTFIX
String x =txtx.getText();
String y =txty.getText();
String hasil="";
for(int i=0; i<=x.length()-1; i++ ){
for(int j=i+1; j<=x.length()-1; j++){//////////////
hasil += ""+ x.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
hasil += "\n" ;
for(int i=0; i<=y.length()-1; i++ ){
for(int j=i+1; j<=y.length()-1; j++){//////////////
hasil += ""+ y.charAt(j);
}
jta.setText(hasil);
hasil += ", ";
}
}
7.CONCAT
String x,y;
x=txtx.getText();
y=txty.getText();
jta.setText(x+y);
Diatas adalah coding untuk mencari Head, Tail, Prefix, ProperPrefix, Postfix, ProperPostfix, Concat. Untuk pengertian apa itu prefik dll akan saya posting di kemudian hari.