arrays - Java args Incompatible types -


sorry, i'm java noob. idea why code isn't compiling? work such can enter 2 arrays @ command line, , have them used "findna" method. if elements in array match na printed on new line, if there no match original value in "array" printed. in advance!

  class nafam {     static void findna(string[] array, string[] lookuparray) {         int i;         int j;         (i = 0; < array.length; i++) {             (j = 0; j < lookuparray.length; j++) {                 if (array[i] == lookuparray[j]) {                     system.out.println("na");                 } else {                     system.out.println(array[i]);                 }             }         }     }     public static void main(string args[]) {         string[] array = args[0];         string[] lookuparray = args[1];         findna(array, lookuparray);      } } 

string[] array = args[0]; 

you setting array equal string (args[0] returns string has index of 0 inside array).

same here:

string[] lookuparray = args[1]; 

if want input 2 arrays , check if they're equal try this:

import java.util.scanner;  class nafam {     static void findna(string[] array, string[] lookuparray) {         boolean equal = true;         (int = 0; < array.length; i++) {             if (array[i]!=lookuparray[i]) {                 equal=false;             }         }         if (equal==true) {              system.out.println("na");         } else {             system.out.println(array[0]);         }     }      public static void main(string[] args) {         //create new scanner         scanner scan = new scanner(system.in);         //create integer size of array want input         int size1;         //input size         size1 = scan.nextint();         //create , input arrays         string[] arrayone = new string[size1];         string[] arraytwo = new string[size1];          (int = 0; < size1; i++) {             arrayone[i] = scan.next();         }         (int = 0; < size1; i++) {             arraytwo[i] = scan.next();         }         findna(arrayone,arraytwo);     } } 

haven't tested yet should work.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -