Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 You haven't learned Java if...
Index -> Programming, Java -> Java Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Wed Dec 17, 2008 1:20 pm   Post subject: You haven't learned Java if...

You haven't succeeded in learning Java if...

This is aimed at students taking introductory programming classes in high school. Yes, I realize the quality of instruction may vary, but you are not limited to what your teacher provides. Try reading my Introduction to Java, for instance.


  • You haven't learned Java if... all of your code lives inside your main method.

    You should make the opportunity to factor out common code and give useful names to chunks of code by using methods.
  • You haven't learned Java if... you haven't defined your own class(es).

    To even begin understanding object-oriented programming, you must experiment. If you have not defined your own class, you cannot have thoroughly experimented.
  • You haven't learned Java if... you use static variables inside your class, which are modified by static methods.

    This is no different than using global variables in something like C. It means you do not appreciate good code organization.
  • You haven't learned Java if... you use arrays instead of a Collection.

    Collections are more flexible than arrays and offer the opportunity to get experience with polymorphism.
  • You haven't learned Java if... you haven't implemented an interface.

    Interfaces are a hugely important part of working with Java, and implementing them is a huge step in understanding Java.
Sponsor
Sponsor
Sponsor
sponsor
S_Grimm




PostPosted: Wed Dec 17, 2008 7:48 pm   Post subject: RE:You haven\'t learned Java if...

lol. I guess I don;t know Java then. I use still arrays for things that require a set amount of variables.

BTW: Is there a tutorial on Collections around here?
andrew.




PostPosted: Tue Dec 30, 2008 8:09 pm   Post subject: RE:You haven\'t learned Java if...

I know everything except the last two. And also, is there a Collections tutorial? Someone should make it.
wtd




PostPosted: Wed Dec 31, 2008 12:26 am   Post subject: RE:You haven\'t learned Java if...

I talk about both subjects in my Introduction to Java, which is available on the wiki.
Zren




PostPosted: Sun Nov 21, 2010 5:43 pm   Post subject: RE:You haven\'t learned Java if...

Ignoring the spam above. Just wondering if by learning abstract classes, you'd clear the last thing on that list? I've never made an Interface, but they seem slightly similar.
SmokeMonster




PostPosted: Sun Nov 21, 2010 11:41 pm   Post subject: Re: RE:You haven\'t learned Java if...

Zren @ Sun Nov 21, 2010 5:43 pm wrote:
Ignoring the spam above. Just wondering if by learning abstract classes, you'd clear the last thing on that list? I've never made an Interface, but they seem slightly similar.


I'd say so since Abstract Class is pretty much a superset of an interface.
Barbarrosa




PostPosted: Sun Nov 21, 2010 11:58 pm   Post subject: Re: You haven't learned Java if...

@Zren: Nope, you don't clear that last one by using abstract classes. I'd add abstract classes to the list, although implementing a child class for an abstract collection parent class could certainly help in that learning process. You can't do as much in an interface as you can in an abstract class, not NEARLY as much. They're more flexible, though, in some ways.

@wtd: Are there particular situations where arrays perform better than other ways to store lists of data, or are they pretty much always trumped by the Collections classes? I read somewhere that it takes up less memory to make an empty array than an object, so I thought they might have the advantage of allocating less memory than a collection class. I understand that the collection classes (e.g., the HashMap) provide valuable ways of storing large amounts of data, which are often more practical than an array for both data retrieval and usage.
TokenHerbz




PostPosted: Sat Mar 17, 2012 9:18 pm   Post subject: RE:You haven\'t learned Java if...

I am curious to know these answers and would also like to see a link to a collections tutorial.
Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: Sat Mar 17, 2012 10:17 pm   Post subject: Re: RE:You haven\'t learned Java if...

TokenHerbz @ Sat Mar 17, 2012 9:18 pm wrote:
I am curious to know these answers and would also like to see a link to a collections tutorial.

Same here...
I have done everything except the last two...
DemonWasp




PostPosted: Sat Mar 17, 2012 10:18 pm   Post subject: RE:You haven\'t learned Java if...

To clear up a few things from the last several posts:

1. Abstract classes and interfaces are similar in some respects (can't instantiate either), but critically different otherwise. You can implement several different interfaces, but you can only ever extend one class (nearly all classes extend another class, even without the 'extends' clause: they extend Object. Interfaces cannot contain implementation details, only the critical bits of public API. They are both useful in different contexts.

2. Arrays perform (slightly) better for random-access operations than ArrayLists. They are also the fastest sequential-access data structure (though ArrayLists are again very close). They are terrible for any operations where the size changes. Most Java programmers, even when they know the initial size beforehand and don't plan to add or remove objects, will use List<Type> over Type[]. Doing so provides much more flexibility in case anything needs to be changed later. In addition, nearly all Java libraries prefer to use Lists over arrays, so most data-passing is done in Collections.

3. I couldn't find wtd's Introduction to Java in 30 seconds, so I gave up. Try this instead: http://docs.oracle.com/javase/tutorial/collections/
Display posts from previous:   
   Index -> Programming, Java -> Java Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: