• Post Reply Bookmark Topic Watch Topic
  • New Topic

Program won't compile  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a code that will not compile even though it is showing no errors in the actual code. I'm not sure what exactly is wrong. What do I need to change to make this thing run?

This is the error message I get when it tries to compile:

Exception in thread "main" java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Matcher.java:536)
at Test4.main(Test4.java:52)



 
Saloon Keeper
Posts: 7994
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

Exceptions are thrown when your program runs, so it must also have compiled.

In this case, it throws an exception because you call group(0) even though no match has been found. You will see why when you try to match the braces in your program.
 
Tim Johns
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I take that out I get this on the console:


Top 5 Words in Movie Review:

half appears 179 times
your appears 76 times
remote appears 64 times
without appears 59 times
introduced appears 58 times

Words in positive that appear more than 5 times in movie review

Exception in thread "main" java.lang.IllegalStateException: Scanner closed
at java.util.Scanner.ensureOpen(Scanner.java:1070)
at java.util.Scanner.hasNext(Scanner.java:1334)
at Test3.main(Test3.java:89)

 
Stephan van Hulst
Saloon Keeper
Posts: 7994
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should post the new code, and make sure you align every brace with the line that contains the opening brace.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!