Skip to content

Instantly share code, notes, and snippets.

@gitaficionado
Created March 9, 2021 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitaficionado/93cc673927b2d202bbbeee0067b4d6df to your computer and use it in GitHub Desktop.
Save gitaficionado/93cc673927b2d202bbbeee0067b4d6df to your computer and use it in GitHub Desktop.
Beginning code for StringStatsArray class
import java.util.Scanner;
public class StringStatsArray{
private final String[] arr;
public StringStatsArray(String[] a){
arr = a;
}
/* Iterate through and cancatenate all values surrounded by quotes except last and follow each with a comma.
Create string with a "{" the beginning and end it with a "}".
*/
/*
Create a sum variable as 0. Then, itereate through and add each String length. Be sure to return sum divided
by array length (cast to double if sum as an int).
*/
/*
Iterate through each value in array in turn. If value is equal to target return the index.
Finally, at the end of iteration return -1 as item is not found.
*/
/*
Create booleans for alphabetical/reverse alphabetical sequence as true. Then, iterate through all except first value. You
should also be able to compare the value to previous one useing compareTo method.
*/
/* Works in the same way as sortStatus in the NumStatsArray class, but uses
* the compareTo method to determine if one String appears alphabetically
* after the other.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment