Im new to Java programming of course so im having trouble with this program i have to write
Can anyone give me some tips on inheritance?

public class Trailer
{
   public Trailer(String anID)
   {
      trailerID = anID;
   }
   public Trailer getNextTrailer()
   {
      return nextTrailer; 
   }
   public void setNextTrailer(Trailer newTrailer)
   {
      nextTrailer = newTrailer; 

   }
   public void loadGood(Goods aGoods)
   {


   }
   public double getValue()
   {
      double value;
      value = theGood.getValue();
      return value;   
   }
   public void display()
   {
      System.out.println("Trailer " + trailerID + theGood.getDescription());

   }
   private String trailerID;
   private Trailer nextTrailer;
   private Goods theGood;
}

public class Truck
{
 public Truck(Driver aDriver, String aTruckID)
 {
  theDriver = aDriver;
  truckID = aTruckID;
     totalValue = 0.0;
 }
 public void connectTrailer(Trailer aTrailer)
 {
 }
 public void displayInformation()
 {
  System.out.println("Information on Truck " + truckID + ":");
  System.out.println("Driver is " + theDriver);
  System.out.println(display());
  System.out.println("The total value of the goods on the truck is $");
 }

 private String truckID;
 private Driver theDriver;
 private Trailer firstTrailer;
 private double totalValue;
}

I have other classes which inherit each other but they arn't the problem
The problem is with the system.out.println parts as the error says

Trailer.java:39: 'void' type not allowed here
System.out.println("Trailer " + trailerID + theGood.getDescription());
^
1 error

Why arn't i aloud to put a 'void' method in an output??

I'm fairly new to JAVA myself, but it looks to me like you are using a void method to output to the system (ie your System.out.println() inside void display()).
Anything declared as void is unable to output.

Also, where does the line in question access the getDescription() method? I can't find it in your quote.

Please anyone, correct me if I am wrong. It is the best way for me to learn.

My friend U did not what U really want to do U R program does not has not main where the program will exactly get started to execute itself. Please write me in detail what U really wann,t to do. I think U R strongly mistaken in U R concept............

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.