aspose file tools*
The moose likes Beginning Java and the fly likes User Created Methods/Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "User Created Methods/Classes" Watch "User Created Methods/Classes" New topic
Author

User Created Methods/Classes

P. Sagdeo
Ranch Hand

Joined: Nov 13, 2003
Posts: 67
Exactly what is a user created method/class?

Can a user created class extend a non user-created one (i.e. extends JApplet). Likewise, can a user created class implement anything? Is actionPerformed a user-created class (you put the contents in, but essentially its from the ActionListener interface, non user-created.

Sorry if I'm sounding redundant or just plain weird,
Parth
P. Sagdeo
Ranch Hand

Joined: Nov 13, 2003
Posts: 67
Can anyone perhaps give a definition?
Thanks again,
Parth
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

"User created XXX" is not a formal (or informal) concept in Java, so I think it would be hard to give you a definition. It's just a couple of English words, which presumably mean "a class (or method) written by the user."

Maybe if you gave us some context -- i.e., where you came across this term and why you need it to be clarified -- we could help more. But as it is, it's tautological at best.


[Jess in Action][AskingGoodQuestions]
P. Sagdeo
Ranch Hand

Joined: Nov 13, 2003
Posts: 67
Well, its all about what we've been learning in school. Generally, there hasn't been that much of an explicit definition. Obviously, a class that does not implement or extend anything, whether or not it uses methods not created by the same programmer is user-created, and obviously the instantiation of say, JFrame is totally non user-created. However, there are some things that seem to be borderline. The main example I was thinking of was actionPerformed. My dilemma is that the basis for this method was not fully written by me, but the actual meaningful content was. I'm leaning toward the direction of actionPerformed is a user-created mthod, as is something extending JPanel, as long as it is different from the original, but the instantiation of JFrame in the form of JFrame j=new JFrame(); is not. Just needed a more professional opinion on the topic.
Thanks,
Parth
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
EVERY class extends Object (either directly or indirectly) whether you create it, the person next to you, or someone at Sun.
Even classes James Gossling create extend Object.

That should answer your second question.

If classes you create couldn't implement interfaces or extend other classes they'd be pretty useless right?
And so would those interfaces which after all are there to be implemented by someone.
That should answer your third question.

As to "user created", everyone is a user. Even the people writing the core APIs are users.
That should answer your first question.


42
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
"User Defined Types" rings a bell. Is that an official term in C or C++ or something? The ability to define your own types - classes and interfaces and the like - is a key bit of coolness in the whole OO world. It's so fundamental that we don't even think about it. Pretty much everything we write must be in a user defined class of some kind.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Originally posted by Stan James:
"User Defined Types" rings a bell. Is that an official term in C or C++ or something?


It rings a pretty old and creaky bell, now that you mention it. C++ people used to use this term, back in the dark ages before there was a standard library. The more modern term for the same concept is "abstract data type", or ADT; again, for the same reason as Jeroen described: because there's no useful distinction between classes written by a "user" and the standard library classes.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
UDT stems from C where you have built-in types and compound types you define yourself (records).
It's also used in other languages.

In Java and other OO languages where types defined by end users plug into the same object hierarchy as those defined by the language creators there is no such distinction.
Java might be a special case if you consider everything except the primitives to be UDTs, part of which happen to be shipped by the same people that bring the built-in types.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: User Created Methods/Classes
 
Similar Threads
overriding a static method
Spring singleton Beanscope
tomcat and java on Linux
Difference between static and non-static members.
confusion regarding top level nested or static inner class