Skip to content
Guest Big Announcement

Featured Replies

Hello gang, I want to code in java a program that reads words and tells me how much did I input into them. However, I don't have a clue except using the input scanner to help me do it. What can or is possible to detect words

Updated by Nyanta

Solved by Guest

Hello gang, I want to code in java a program that reads words and tells me how much did I input into them. However, I don't have a clue except using the input scanner to help me do it. What can or is possible to detect words

import java.util.*;

public class Input{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);

SOP("input: ");

String input = keyboard.nextLine(); //thats your input
}
}

I hate java its so ugly

  • Solution

Hello gang, I want to code in java a program that reads words and tells me how much did I input into them. However, I don't have a clue except using the input scanner to help me do it. What can or is possible to detect words

wait no I'm so sick I f**ked up

 

just use .split method

 

String words[] = input.split(" ");

SOP(words.length + " words");
  • Author

wait no I'm so sick I f**ked up

 

just use .split method

 

String words[] = input.split(" ");

SOP(words.length + " words");

Thnx Bae <3 hope you get well soon tumblr_nxw98wylYH1tb7a4bo1_500.gif don't forget to drink lots of soup

Updated by Nyanta

Create an account or sign in to comment

Featured Content

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.