Need help,homework

T

theunknowable

Nooblet here, I need to write this application, I got as far as making 6
empty classes and originally needed to use swing, though since I need to
learn swing I may just make it a console application and get less points
for it. I need to be able of writing to disk the data (utilizing user
input), deleting it when I want too and show I understand how classes
work. While I understand extends, I don't quite understand what implement
does.

Extends allows you to use the methods and variables of the class you
extended (inheritance). Implement seems similar?

Anyways, since I only have 1 day to do this and I've been trying to do
this for weeks, what are the classes available that will allow me to:

1.) Write a plain text file to disk?
2.) read the file?
3.) delete the file?
4.) check for the existence of the file?
5.) search for the file?
6.) compare files?

Where can I learn more about these specific classes? Any example code that
is small and simple to read? :(
 
L

Lew

Nooblet here, I need to write this application, I got as far as making 6
empty classes and originally needed to use swing, though since I need to
learn swing I may just make it a console application and get less points
for it. I need to be able of writing to disk the data (utilizing user
input), deleting it when I want too and show I understand how classes
work. While I understand extends, I don't quite understand what implement
does.

Extends allows you to use the methods and variables of the class you
extended (inheritance). Implement seems similar?

'extends' is the keyword to inherit from a class, including implementation of methods.

'implements' is the keyword for a _class_ to inherit from an interface, including only
method signatures from the interface and leaving details of implementation entirely
up to the implementing class.

An interface can use 'extends' to inherit from another interface. Because an interface
contains no implementation, it cannot 'implements' an interface.
Anyways, since I only have 1 day to do this and I've been trying to do

You're going to have a hard time. Usenet isn't necessarily a one-day turnaround, and
learning Java can take a few days.
this for weeks, what are the classes available that will allow me to:

Tutorials and Javadocs.

Tutorials:
http://docs.oracle.com/javase/tutorial/

Javadocs:
http://docs.oracle.com/javase/7/docs/api/
http://docs.oracle.com/javase/7/docs/api/java/io/File.html
plus
http://docs.oracle.com/javase/7/docs/api/java/io/FileFilter.html
plus
http://docs.oracle.com/javase/7/docs/api/java/io/FilenameFilter.html
plus glue code.
6.) compare files?
Read the files and compare contents. You'll need to be more specific about what you
mean by "compare".
Where can I learn more about these specific classes? Any example code that
is small and simple to read? :(

http://lmgtfy.com/?q=Java+simple+file+I/O
 
L

Lew

Roedy said:

OP, you'd be better off with the Oracle documentation and Google, whereby you
can get more accurate and insightful information.

Roedy is fond of driving traffic to his site from here. You might find something
somewhat useful there, but you're far more likely to benefit from authoritative sources.
 
A

Arne Vajhøj


I am not sure that is good advice.

#implements is a keyword used on class or interface statements.

class and interface are not statements.

And an interface can not implements by definition.

#Let’s say you had a TV class to deal with television sales. There are
#two kinds of variables:
#
# static variables that track facts about all televisions in
#general, e.g. total sold or a list of manufacturers.

That sounds like an awful design to me.

#The throws clauses about Exceptions in the interface’s methods must
#exactly match the throws clauses of the implementing methods.

No.

The implementing method can not throws an exception not in
the interface, but it does not need to throws all exceptions
in the interface.

Arne
 
R

Robert Klemme

On 12/11/2012 9:37 PM, Roedy Green wrote:

#The throws clauses about Exceptions in the interface’s methods must
#exactly match the throws clauses of the implementing methods.

No.

The implementing method can not throws an exception not in
the interface, but it does not need to throws all exceptions
in the interface.

<nitpick>The implementing class can choose to declare a more restrictive
throws clause, which means, sub classes of declared exceptions in the
interface as well as a shorter throws clause. And it is allowed to
throw all exceptions which are mentioned in the throws clause or sub
classes of them.</nitpick>

Kind regards

robert
 
A

Arne Vajhøj

<nitpick>The implementing class can choose to declare a more restrictive
throws clause, which means, sub classes of declared exceptions in the
interface as well as a shorter throws clause. And it is allowed to
throw all exceptions which are mentioned in the throws clause or sub
classes of them.</nitpick>

Good point.

"not in the interface" must be "not instance of one in the
interface" or "not assignable to one in the interface".

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Homework in C - Help Needed 1
I need some help with homework 1
I need help with homework 1
Question on homework.... 1
Need Advice 10
Need help with this script 4
Help 1
Need your help for a young programmer 0

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top