Skip to content

Latest commit

 

History

History

Array Length

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Length

  1. Start with this code:
import java.util.Arrays;

public class Newsfeed {
  
  String[] topics = {"Opinion", "Tech", "Science", "Health"};
  int[] views = {0, 0, 0, 0};
  
  public Newsfeed(){

  }
    
  public String[] getTopics(){
    return topics;
  }
  
  public int getNumTopics(){
    
  }
  
  public static void main(String[] args){
    Newsfeed sampleFeed = new Newsfeed();
    
    System.out.println("The number of topics is "+ sampleFeed.getNumTopics());
   
  }
}

  1. In the method getNumTopics(), return the length of the topics array.

Example solution can be found in the Newsfeed.java file.