I have been asking similar questions before so this may be taken down but I feel like the code I have now should work but it doesn't.
String post [] = new String [100];
System.out.println("\nType your post");
String userPost = input.nextLine();
post[0] = userPost;
String hashtags ="";
for (int i = 0; i<post.length && post[i]!=null;i++){
String[]words = post[i].split(" ");
for(int j=0;j<words.length;j++){
if(words[j].trim().startsWith("#")){
hashtags+=words[j].trim() + " ";
}
}
}
if(hashtags.trim().isEmpty())
System.out.println("No hashtags were typed");
else
System.out.println("Hashtags found: " + hashtags );
I feel like this should work but when running this code, it skips asking for user input and immediately prints No hashtags were typed.