Beruflich Dokumente
Kultur Dokumente
Syllabus
Link to syllabus As of now my webpage will have all material for the course
http://www.eecs.ucf.edu/~hlugo
Problem Solving
1. 2. 3. 4. Understand the problem Dissect the problem into manageable pieces. Design a solution. Consider alternatives to the solution to refine it. 5. Implement the solution. 6. Test the solution and fix any problems that exist.
History of Java
Java was developed in 1995 be James Gosling who works at Sun Microsystems. Java's ability to execute programs on the WWW caused an initial buzz. However, the language has continued to gain in popularity because of its object-oriented design. This design is very well-suited for very large programming projects. Many academics even feel that Java is an excellent first programming language to learn. Java teaches the concept of objects very well. Other languages, such as C++, do not reinforce the concept quite as well. Although C++ is good for learning memory management. Recently Sun was bought by Oracle.
A Java Program
1. // Knights.java 2. // Arup Guha 3. // 1/9/07 4. // A very simple Java program that prints to the screen. 5. public class Knights { 6. 7. 8. 9. 10. 11. 12. } /* This is the main function of the program */ public static void main(String[] args) { System.out.println("GO KNIGHTS!!!!!!!"); }
Multi line comments follow the C convention of /* anything between this is a comment */, as shown on lines 6 8
Class Definition
Line 5 presents the definition of a class
All java code resides within classes, and each class must have a name.
In main class the name should be the same filename
Understanding Main
There are several keywords on the definition of main
1) public: access from everywhere 2) static: the method is the same for all instances of the class 3) void: return type, in this case none 4) String[] args: parameters to main. Equivalent to Cs int argc, char** argv
System.out.println
On line 10 we our first line to write something to the stdout or console in this case System.out.println works as printf in C, however it is much simpler to use since it does not require format specifiers (i.e. %c, %s, %d, %f, etc.) System.out.printf does exits as well and it is used just liked in C Other standard streams include System.in and System.err
Variable Names
Are case sensitive Can contain letters, underscores, and numbers Should not start with numbers Should be descriptive of the task, they can have any number of characters