Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #20235 > unrolled thread
| Started by | theunknowable@lavabit.com |
|---|---|
| First post | 2012-12-11 00:21 +0000 |
| Last post | 2012-12-14 20:59 -0500 |
| Articles | 7 — 5 participants |
Back to article view | Back to comp.lang.java.programmer
Need help,homework theunknowable@lavabit.com - 2012-12-11 00:21 +0000
Re: Need help,homework Lew <lewbloch@gmail.com> - 2012-12-10 17:05 -0800
Re: Need help,homework Roedy Green <see_website@mindprod.com.invalid> - 2012-12-11 18:37 -0800
Re: Need help,homework Lew <lewbloch@gmail.com> - 2012-12-11 19:30 -0800
Re: Need help,homework Arne Vajhøj <arne@vajhoej.dk> - 2012-12-12 20:42 -0500
Re: Need help,homework Robert Klemme <shortcutter@googlemail.com> - 2012-12-14 08:03 +0100
Re: Need help,homework Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 20:59 -0500
| From | theunknowable@lavabit.com |
|---|---|
| Date | 2012-12-11 00:21 +0000 |
| Subject | Need help,homework |
| Message-ID | <ka5ua2$2k8$1@dont-email.me> |
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? :(
[toc] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-12-10 17:05 -0800 |
| Message-ID | <fb2c1476-86cf-4478-abec-f03647df7f22@googlegroups.com> |
| In reply to | #20235 |
theunk...@lavabit.com wrote: > 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/ > 1.) Write a plain text file to disk? http://docs.oracle.com/javase/tutorial/essential/io/index.html http://docs.oracle.com/javase/7/docs/api/java/io/FileWriter.html > 2.) read the file? http://docs.oracle.com/javase/7/docs/api/java/io/FileReader.html > 3.) delete the file? http://docs.oracle.com/javase/7/docs/api/java/io/File.html > 4.) check for the existence of the file? http://docs.oracle.com/javase/7/docs/api/java/io/File.html > 5.) search for the file? 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%2FO -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-12-11 18:37 -0800 |
| Message-ID | <udrfc8t6icar3vihtetsc1vrqss25m473l@4ax.com> |
| In reply to | #20235 |
On Tue, 11 Dec 2012 00:21:22 +0000 (UTC), theunknowable@lavabit.com wrote, quoted or indirectly quoted someone who said : >While I understand extends, I don't quite understand what implement >does. see http://mindprod.com/jgloss/implements.html http://mindprod.com/jgloss/class.html http://mindprod.com/jgloss/interface.html -- Roedy Green Canadian Mind Products http://mindprod.com Students who hire or con others to do their homework are as foolish as couch potatoes who hire others to go to the gym for them.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-12-11 19:30 -0800 |
| Message-ID | <97bcd4ff-529c-404c-94d6-0a92471fc302@googlegroups.com> |
| In reply to | #20268 |
Roedy Green wrote: > theunknowable... wrote, quoted or indirectly quoted someone who said : > >> While I understand extends, I don't quite understand what implement >> does. > > see http://mindprod.com/jgloss/implements.html > http://mindprod.com/jgloss/class.html > http://mindprod.com/jgloss/interface.html 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. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-12-12 20:42 -0500 |
| Message-ID | <50c93283$0$285$14726298@news.sunsite.dk> |
| In reply to | #20268 |
On 12/11/2012 9:37 PM, Roedy Green wrote: > On Tue, 11 Dec 2012 00:21:22 +0000 (UTC), theunknowable@lavabit.com > wrote, quoted or indirectly quoted someone who said : >> While I understand extends, I don't quite understand what implement >> does. > > see I am not sure that is good advice. > http://mindprod.com/jgloss/implements.html #implements is a keyword used on class or interface statements. class and interface are not statements. And an interface can not implements by definition. > http://mindprod.com/jgloss/class.html #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. > http://mindprod.com/jgloss/interface.html #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
[toc] | [prev] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2012-12-14 08:03 +0100 |
| Message-ID | <aj01auFganpU4@mid.individual.net> |
| In reply to | #20280 |
On 12/13/2012 02:42 AM, Arne Vajhøj wrote: > On 12/11/2012 9:37 PM, Roedy Green wrote: >> http://mindprod.com/jgloss/interface.html > > #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
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-12-14 20:59 -0500 |
| Message-ID | <50cbd986$0$289$14726298@news.sunsite.dk> |
| In reply to | #20318 |
On 12/14/2012 2:03 AM, Robert Klemme wrote: > On 12/13/2012 02:42 AM, Arne Vajhøj wrote: >> On 12/11/2012 9:37 PM, Roedy Green wrote: > >>> http://mindprod.com/jgloss/interface.html >> >> #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> Good point. "not in the interface" must be "not instance of one in the interface" or "not assignable to one in the interface". Arne
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web