Another thing, if you're working with time, please don't use Calendar, but use the new java.time classes.
Alex Lucard wrote:Thank you for you help but how do I return the object
I get an error incompatible types at run time.
Can someone show me in code how to do this or a page that will give java object return type example
You may need to give us more details ... ie. TellTheDetails.
We don't exactly know what you changed, nor the exact error message that you got.
Alex Lucard wrote:I added this to the class recardObj
Now in netbeans i get this error on the line with the new code "Incompatible type: int connot be converted to RecordObj …."
"public RecordObj returnCurrentHour()"
Let's take this method signature and examine it. First it is "public" which means anyone can call it. So far so good. Second, it's return type has been set to "RecordObj." Is that what you wanted to do? Third, it is named "returnCurrentHour()" suggesting you want to return the current hour. What type is the currentHour variable? Does it match the return type of the method? This is what the compiler is trying to tell/ask you.
1) I would like to make a class and turn it into an object called Obj. like a getters and setters
2) Next make a new class lets call this class A and store a value in one of the fields in the Obj getters and setters.
3) Then make a new class called class B and access the values from the Obj class and print them out.
That is all I am looking for is how to pass values into a object from one class and access that same object from other classes.
Can someone show example code or tell me what I need to change in my code to make this work.
You say that you want to create an object, but you can't do this without context. Where is the object created? If you want to do all of this in the same method, you first create the object using the new keyword, then you pass it to the appropriate method of class A, and then you pass it to the appropriate method of class B.
Your original code differs from this in that you first call the method of A which creates its own object. you should first create r, and then pass it to currentHour().