Sublime Forum

I get no output w/ ST3 but it's vice versa in NetBeans

#1

Hi,

I’ve just written a simple code for splitting a sentence into its words but the didn’t work with ST3’s build & run system. Later on, I decided to test the code in NetBeans and it just worked fine!

What may the problem be? Does anyone have any idea?

Thanks in advance

Here is the code:

import java.util.Scanner;

public class problem1 {

	public static void main(String[] args) {
		
		Scanner input = new Scanner(System.in);
		System.out.println("Please enter a sentence");
		String sentence = input.nextLine();

		// Method 1 for splitting the sentence into its each word
		char space = ' ';
		for (int i = 0; i < sentence.length(); i++) {
			if (sentence.charAt(i) != space) {
				System.out.print(sentence.charAt(i));	
			}
			else {
				System.out.println();
			}	
		}

		// Method 2 for splitting the sentence into its each word
		String word = "";
		for (int i = 0; i < sentence.length(); i++) {
			if (sentence.charAt(i) != space) {
				word = word.concat(String.valueOf(sentence.charAt(i)));
			}
			else {
				System.out.println(word);
				word = "";
			}
		}
		System.out.println(word);
	}
}
0 Likes

#2

ST doesn’t support standard input from the built in build system, so your code probably “hangs” waiting for input on the first line

0 Likes

#3

Yeah, since I get no response after I type a sentence.

Then, what is the solution for this trick?

0 Likes

#4


1 Like

#5

The first link didn’t work for me. I got a Could not find or load main class error and the other one thrilled me but unfortunately, that package works fine for many programming languages except Java :smiley:

Anyway, thank you for your time and interest.

0 Likes