Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:23:31+00:00 2026-06-13T17:23:31+00:00

so my homework is asking me only for class methods, but it’s requiring i

  • 0

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:

public class findFourLetterWord(String[] strings) {
   public static void main(String[] args) {
   for (int i = 0; i < strings.length; i++)
      if (strings[i].length()==4)
          return strings[i];
   return null;
}
}

and here’s the errors i’m getting:

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

any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:23:33+00:00Added an answer on June 13, 2026 at 5:23 pm

    Assuming you are running Eclipse as your IDE, if you rearrange your code to something like this:

    public class FindFourLetterWord {
    
      public static void main(String[] args) {
    
         for (int i = 0; i < args.length; i++) {
    
            if (args[i].length() == 4) {
               System.out.println(args[i]);
               break;
            }
         }
      }
    
    }
    

    and then save the changes (which automatically triggers the compilation), you can run your compiled program (.class file) from a command line, with a few arguments (namely contained in args), being the words search list:

    $> cd /path/to/your/FindFourLetterWord.class/file
    $> java FindFourLetterWord aba abba ab a
    

    You’ll get the first 4-letter word among the words specified (abba).
    This way you essentially invoked main method of the class (supplying it with a few String arguments), which is the entry point for each Java program.
    As others already said, try to pick up on the basics first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'll admit that this is a homework assignment, but I'm not asking you
It's from homework, but I'm asking for a general method. Calculate the following code's
Not any homework, but seem to have got lost while doing basics, hence asking.
I got a homework assignment asking me to invoke a function without explicitly calling
This is part of a homework assignment. I've got several questions asking find the
Homework. Dice Game. I've got an array that represents five rolls of a die.
I've been asked (as part of homework) to design a Java program that does
I'm trying to do my homework that is restricted to only using sed to
I am working on a homework so i am not asking for code, i
I'm not asking for anyone to do this homework for me, but I bring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.