Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Online Java Compiler
- // Use this editor to write, compile and run your Java code online
- //taskOne - Arrays
- class HelloWorld {
- // common items
- public static void main(String[] args) {
- //first solution
- String [] arr2={"10","hey","4","hello"};
- String [] arr1 ={"Hey","hello","2","4"};
- int i=0;
- int j=0;
- for (i=0;i<arr2.length;i++){
- for(j=0;j<arr1.length;j++){
- if (arr1[j]==arr2[i]){
- System.out.print(arr1[j]+" ");
- }
- }
- }
- System.out.println();
- String [] arr3 ={"i","love","to","code"};
- String [] arr4 ={"code","i","love","to"};
- for(String item4:arr4){
- for(String item3:arr3){
- if(item3.equals(item4)){
- System.out.print(item3+" ");
- }
- }
- }
- //System.out.println("Hello, World!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement