I am trying to count the number of terms in a string after it has been split... what is the best way for me to do so? this is the problem I am trying to solve:
Create a program that reads in one line from the user and repeats the line back with all four-letter words removed.
Here is what I have so far...
import java.util.*;
public class StringEx1{
public static void main(String[]args){
String mytext;
Scanner ab= new Scanner(System.in);
System.out.println("Enter text: ");
mytext=ab.nextLine();
String [] mytext=mytext.split(" ");
@Mick Mnemonic answered the question perfectly with "
In Java, length is a property (field) of the array, not a method; remove the parenthesis." Thank you for everyone's help!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.