Advertisement
tchenkov

first object string concatenation

May 9th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Created by todor on 9.05.2017 г..
  5.  */
  6. public class P06_StringsAndObjects {
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         String string1 = scan.nextLine();
  10.         String string2 = scan.nextLine();
  11.        
  12.         myString myFirstString = new myString();
  13.         myFirstString.setStringValue(string1);
  14.        
  15.         myString mySecondString = new myString();
  16.         mySecondString.setStringValue(string2);
  17.        
  18.         String string3 = myFirstString.concatenateWith(mySecondString);
  19.        
  20.         System.out.println(string3);
  21.     }
  22. }
  23.  
  24. class myString {
  25.     String stringValue;
  26.    
  27.     public String getStringValue() {
  28.         return stringValue;
  29.     }
  30.    
  31.     public void setStringValue(String stringValue) {
  32.         this.stringValue = stringValue;
  33.     }
  34.    
  35.     public String concatenateWith(myString string2){
  36.         return  getStringValue() + " " + string2.getStringValue();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement