Results 1 to 4 of 4
Thread: Java code not compiling!
- 11-25-2012, 08:32 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 2
- Rep Power
- 0
Java code not compiling!
But my program is not returning "dt" or "delieveredtime" to be precise Its seriously pissing me off i feel like throwing my computer out the windowJava Code:/** * Write a description of class Order here. * * @author (your name) * @version (a version number or a date) */ public class Order { // instance variables - replace the example below with your own private String CustomersName; //This is the customers name private String description; //This is the description private double totalcost; //This is the total cost private Time deliveredTime; //This is the time it got delivered private Time callInTime; //This is the Time it was called-in private int orderRef; //This is the order reference number public void setOrderReference(String cn, String de, double tcost, Time dt, int or) { CustomersName = cn; description = de; totalcost = tcost; deliveredTime = dt; orderRef = or; } public int getOrderNo() { return orderRef; } public void getDescription() { return dt; } public Time getCallInTime() { return callInTime; } /** * An example of a method - replace this comment with your own * * @param y a sample parameter for a method * @return the sum of x and y */ public int sampleMethod(int y) { // put your code here return x + y; } }
this is exactly what is not allowing me to compile
public void getDescription()
{
return dt;
}
what on earth is going wrong?!!!
-
Re: Java code not compiling!
What is that method declared to return?
For instance this method is declared to return an int:
Java Code:public int foo() { // this line shows the method is declaring that it will return an int return 3; }
What is it in fact trying to return?
- 11-25-2012, 09:27 PM #3
Member
- Join Date
- Nov 2012
- Posts
- 2
- Rep Power
- 0
- 11-25-2012, 09:33 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,589
- Blog Entries
- 7
- Rep Power
- 17
Re: Java code not compiling!
You fixed two things:
1) the return type of the method and
2) what it returns.
The method couldn't return 'dt' because it only existed in another method; 'deliverTime' can be returned because:
1) it exists (it's an object member variable) and
2) it has the right type.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Plz help for some reason this code is not compiling
By webslinger55 in forum JDBCReplies: 1Last Post: 01-31-2012, 08:48 AM -
Help compiling code dynamically
By anarelle in forum Java AppletsReplies: 13Last Post: 07-30-2011, 10:07 PM -
Issue compiling Java Code
By AggressiveFish in forum Java AppletsReplies: 4Last Post: 01-04-2011, 09:10 PM -
Compiling java code from the command line
By alman9898 in forum New To JavaReplies: 5Last Post: 10-13-2010, 03:35 AM -
Help me out in compiling the source code
By aks.nitw in forum Advanced JavaReplies: 3Last Post: 10-17-2008, 08:33 AM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks