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

  • Home
  • SEARCH
  • 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 6362949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:58:25+00:00 2026-05-24T23:58:25+00:00

I created 2 source code files, Shirt.java and ShirtTestArray.java The problem I am facing

  • 0

I created 2 source code files, Shirt.java and ShirtTestArray.java

The problem I am facing is that whenever I try to access the displayShirtInformation() method, I’m not able to do it.. and get an error class,interface,or enum expected

The 2 source files are given below–

Shirt.java–

public class Shirt {

  public int shirtID = 0; // Default ID for the shirt
  public String description = "-description required-"; // default

  // The color codes are R=Red, B=Blue, G=Green, U=Unset
  public char colorCode = 'U';
  public double price = 0.0; // Default price for all shirts
  public int quantityInStock = 0; // Default quantity for all shirts

  public Shirt() {
  }

  public Shirt(int ID, String d, char c, double p, int q) {
    shirtID = ID;
    description = d;
    colorCode = c;
    price = p;
    quantityInStock = q;
  }

  // This method displays the values for an item
  public void displayShirtInformation() {

    System.out.println("Shirt ID: " + shirtID);
    System.out.println("Shirt description:" + description);
    System.out.println("Color Code: " + colorCode);
    System.out.println("Shirt price: " + price);
    System.out.println("Quantity in stock: " + quantityInStock);

  } // end of display method
} // end of class

ShirtTestArray.java —

public void  ShirtTestArray{
  public static void main(String [] args) {
    Shirt [] shirtArray={new Shirt (1,"blue",'b',76.67,4),new Shirt(2,"green",'g',98.79,1),
    new Shirt(3,"green",'g',34.78,90)};

    shirtArray[0].displayShirtInformation();
    shirtArray[1].displayShirtInformation();
    shirtArray[2].displayShirtInformation();

  }
}
  • 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-05-24T23:58:25+00:00Added an answer on May 24, 2026 at 11:58 pm

    The second class should be declared as class, not void:

    public class ShirtTestArray{
           ^
        public static void main(String [] args){
        Shirt [] shirtArray={new Shirt
    
    (1,"blue",'b',76.67,4),new Shirt(2,"green",'g',98.79,1),
        new Shirt(3,"green",'g',34.78,90)};
    
    
    
           shirtArray[0].displayShirtInformation();
           shirtArray[1].displayShirtInformation();
           shirtArray[2].displayShirtInformation();
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used source code of an android app that we created in the past
when a dll is created out of the source code in a given namespaces
How are DLLs created out of C++ source code, and how are they used
I've created a Java project from existing source with an Ant build script in
i created a TTViewController that should show some Informations from a external (web) source.
Delphi 2009 sets the default file format for new source code files to ANSI,
Why are flat text files the state of the art for representing source code?
i am using clear-case source control, i created my vob repository(which has my java
I've got lots of source code files written in various languages, but none of
I created a shared library ( *.so ) using the *.o object code files

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.