Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
The Java programming language
1. The Java programming language
2. Installation

Java is a strongly-typed general purpose programming language first released in 1995.
Oracle now owns Java (since 2009), having purchased what was left of Sun Microsystems.
For installation of Java, see
Java
3. Virtual machine
Following the example of UCSD Pascal p-code and p-code machine in the 1970s, Java compiles to Java byte code and runs on the
JVM (
Java Virtual Machine) .
This allows the same Java byte code to run on multiple platforms, though one must take into account platform differences such as file systems, file name case sensitivity (Linux is case sensitive, Windows is case insensitive and case retentive).
4. Jamas Gossling
Java was developed by James Gosling (also Emacs editor) at Sun Microsystems, appeared in 1995, acquired by Oracle in 2010.
Gossling created Java with a C style syntax so it would be familiar to programmers at the time.
5. Java goals
There were five primary goals in the creation of the Java language:(from Wikipedia)
It must be simple, object-oriented, and familiar.
It must be robust and secure.
It must be architecture-neutral and portable.
It must execute with high performance.
It must be interpreted, threaded, and dynamic.
6. Java history
toaster language (embedded systems)
Internet language (Java applets)
Enterprise language
Android language
The Java standard is maintained by a community process of many committees.
7. Programs
GUI programs (Swing, JavaFX, etc.)
command line programs
web applets to be embedded in web pages
servlets to extend the functionality of web servers
JSP (Java Server Pages) for active server-side content.
8. Object-oriented
Java is class-based and object-oriented.
Java is not a pure object-oriented language, as is SmallTalk, since it has primitive types.
9. Projects and classes
A Java program is a collection of classes, one of which contains a main class.
Each class resides in a separate source file. The name of the class needs to match the name of the file.
The proliferation of classes in a project means a proliferation of source files which can be hard to manage.
10. Java
Like all languages, Java has good parts and it has bad parts.
Java has a strong type system.
Java is type safe.
Are these properties good or bad?
11. Strong typing
Strong typing means that any change to a type can result in changes throughout the project.
Generics were added in 2004 to help address abstractions involving similar code but different types.
12. Primitive types
The strong typing issues are exasperated by the plethora of primitive types.
Consider integers. The following are primitive types.
byte 1 byte
short 2 bytes
int 4 bytes
long 8 bytes
There are no unsigned types but there are unsigned methods to deal with unsigned values.
Should the programmer need to decide on which type to use? Some languages only provide one integer type.
13. Classes
The integer primitive types are different than the Integer class.
There is no structure or record type in Java. Instead, one must use classes to simulate structures or records.
14. Garbage collection
Garbage collection is needed to reclaim unused memory.
This can happen at any time, so for time-critical operations some care is needed (i.e., tricks, etc.) to do the garbage collection at the right time.
15. Language defects
Java equality operator "==" is not what one might think.
Java requires a lot of verbosity that could have been avoided.
Rather than having default parameter values, one must replicate code with overloaded method definitions.
Statements can be used in expressions.
Overriding is automatic, rather than requiring an explicit keyword (fragile base class issue).
16. Hello world
The (command line) Hello world program is more complex than in most languages. The GUI version much more complex.
public class hello {
public hello() {
System.out.print("Hello world\n");
}
public static void main(String [] args) {
new hello_01();
}
}
17. Null
In Java:
A null String is sometimes an empty string.
A null Integer is sometimes a zero.
A null Boolean is sometimes a false
18. Other languages
There are some other languages that are built on Java, or, more precisely, the JVM.
Clojure
Scala
TuProlog (Prolog)
Kotlin (avoids many Java language defects)
JScheme (Scheme)
19. More languages
Groovy
JRuby (Ruby)
Jython (Python)
Rhino (JavaScript)
Oxygene (Pascal)
(and many others)
20. Android
The Google Android operating system is built on a core Linux system and uses Java for the Android operating system applications.
But Google would like to replace Java with Kotlin, a Java alternative.
21. Seeing and thinking

How many triangles do you see?
22. Kanizsa triangle
Do you see the triangle?

There is no triangle! Your brain makes the triangle that you see.
Abstraction involves looking at similarities and differences and filling in missing details - sometimes appropriately, sometimes inappropriately.
23. More triangles
How many triangles do you see now? Do they exist?

To many, the triangle that is seen but does not exist and appears brighter than the surrounding area.
24. Gaetano Kanizsa
This type of illusion was discovered/created by Gaetano Kanizsa who popularized such illusions, in part from his 1976 Scientific American paper on the subject (though he had been working on such ideas for many years before this paper).
25. With dots
The triangle is still seen when just dots are present at the corners.

Can a triangle that does not exist be "
whiter than white"? White is white, right?
26. Necker cube

Here is a Necker cube. Which corner nearest to the viewer?

Do you see the Necker cube now? It does not exist except in your mind.
27. Dijkstra: thinking
The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities. Edsger Dijkstra (computer scientist) Dijkstra, E. (June 18, 1975). "How do we tell truths that hurt?", EWD 498.
How might or does your favorite
IDE (
Integrated Development Environment) effect the way you think and your thinking abilities?
Visual Studio
Eclipse
Emacs
VIM, Nano, Notepad, Notepad++, etc.
28. Thinking
How do you think?
Try not to think in a specific language. Instead, program into a language (from your brain).
Design solutions to solve problems top-down, implement the solutions bottom-up.
29. End of page
30. Acronyms and/or initialisms for this page
3 acronyms omitted (login required)