Note that there are some explanatory texts on larger screens.

plurals
  1. POcompiling class methods in java
    primarykey
    data
    text
    <p>so my homework is asking me only for class methods, but it's requiring i turn in a .java and a .class file. well i've got code that theoretically should work, but it won't compile no matter what i try. for example here's one:</p> <pre><code>public class findFourLetterWord(String[] strings) { public static void main(String[] args) { for (int i = 0; i &lt; strings.length; i++) if (strings[i].length()==4) return strings[i]; return null; } } </code></pre> <p>and here's the errors i'm getting:</p> <pre><code>8 errors found: File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 9] Error: The public type findFourLetterWord must be defined in its own file File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 9] Error: Syntax error on token "(", { expected File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 9] Error: Syntax error on token ")", ; expected File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 9] Error: Syntax error, insert "}" to complete Block File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 11] Error: Cannot make a static reference to the non-static field strings File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 12] Error: Cannot make a static reference to the non-static field strings File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 13] Error: Cannot make a static reference to the non-static field strings File: D:\School\CSC 2310\hw5_elemmons1\FindFourLetterWord.java [line: 14] Error: Void methods cannot return a value </code></pre> <p>any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload