Monday, October 25, 2021

String Array and passing method in java

 In this task, we pass a method and also cover the passing String Array to the method.



Code:


 import java.util.Scanner;
public class StringArray{
  public static void main(String[] args){

      String[] names = {"Babar", "Fakhar", "Kohli", "Gilchrist"};

      //Take Array elements from user
      for(int i=0; i<names.length; i++){
         System.out.print("\nnames[" + i + "] = " + names[i]);
      }
   
  }//main

}//class

OutPut:

No comments:

Post a Comment

String Array and passing method in java

 In this task, we pass a method and also cover the passing String Array to the method. Code:   import java.util.Scanner; public class String...