0

In my search for this answer I have already read the following StackOverflow post.

Definition of a Java Container

My issue (lack of understanding ) at this point as a beginner is also learning the esoteric vocabulary. Therefore, even excellent examples often make little or no sense.

For this question please create an answer for the very, very, green beginner.

The actual question:

For the "Definition of a Java Container" give a tangible example, preferably using the NetBeans project tree, of what a Java Container is. A screen-shot would be very helpful for us extremely visual learners.

For example, if I were trying to answer the question "what is a container file" to a computer 101 student, I would probably not say something like this:"A container or wrapper format is a metafile format whose specification describes how different elements of data and metadata coexist in a computer file.

Rather, I would answer like this: "A container file is a ZIP file, MP3 or MP4 file. The reason it is called a container is that it actually contains many other files - much like a directory."

UPDATE

I found this Wikipedia article that I believe begins a decent explanation.

https://en.wikipedia.org/wiki/Container_%28abstract_data_type%29

For example, according to the above article, a simple example of a "container" in a programming language is an array. In object oriented programming languages fancier arrays such a Lists and Maps are also containers. However, for any beginning programmer reading this post, containers are also Classes that form a chain of inheritance (experts correct my terminology if I am wrong).

For beginners, if you do not know what inheritance is then go study that. There is another Wikipedia article to read.This whole article is describing "containers" in Java.

https://en.wikipedia.org/wiki/Java_collections_framework

To give the sort of example I was originally asking for, if you have NetBeans then go do this:

  1. Create a new class, then inside of it create a new method, as shown below:

     package InformationStorage;
    
     public class MyClass {
    
         public void MyMethod(){
    
         }    
    }
    
  2. Now, inside the method type the command "System", and then type a period. Like this:

      ["Screen shot from NetBeans"][3]
    

Notice the list of methods and other stuff included within "System". If you choose one (for example "out" as in System.out.), then when you type the period after "out" more sub-options appear, and so on.You will eventually end with something like "System.out.println();"

This is an example of Container Classes.

Community
  • 1
  • 1

1 Answers1

0

Frustrated-Me this question is posed just like your name haha. Anyway I will answer. There is allot of programming jargon that will not make sense to a beginner, I wouldn't worry about it at beginner stage. So yes there is a container which is the same as say a Collection (List,Map,Set...Array is maybe one too), which just contains other data members. But then this term is used in another way in Java and other programming languages and frameworks.

What is a container in this sense? Well I guess I would say it's complicated thing that does allot of stuff for you in layman terms. You see, something like programming a website is very complex, and Java as a programming language can be considered verbose by some, this makes for a very difficult time for a developer. So there are all these fancy frameworks, for instance: Spring which may all share some similar concepts such as dependency injection, aspect orientated programming or whatever ever else. Even if you don't know what those things are they are just ways to help the programmer develop a complicated piece of software.

These concepts are often implemented in something that may be called a container. Basically you put your POJO (instances of a java class) in this container, and the container adds functionality to what you have done, via DI, or aspect orientated programing or something else. Usually these containers are built on design patterns such as the proxy or cake or MVC ect.

One might be able to say that a container in this sense does more than just storing your objects/data, but adds additional functionality to make your life easier.

Derrops
  • 7,651
  • 5
  • 30
  • 60