Download Week 3 (June 24 and 29) Introduction to Java Integrated

yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Go (programming language) wikipedia , lookup

Scala (programming language) wikipedia , lookup

Design Patterns wikipedia , lookup

Structured programming wikipedia , lookup

Java syntax wikipedia , lookup

Falcon (programming language) wikipedia , lookup

Abstraction (computer science) wikipedia , lookup

Java (programming language) wikipedia , lookup

Name mangling wikipedia , lookup

Java performance wikipedia , lookup

C++ wikipedia , lookup

Class (computer programming) wikipedia , lookup

Object-oriented programming wikipedia , lookup

C Sharp syntax wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Week 3 (June 24 and 29) Introduction to Java
Integrated Development Environment (IDE)
- a programming environment integrated into a software application that provides a GUI builder,
a text or code editor, a compiler and/or interpreter and a debugger.
(from WengSolamoSlides)
*We will be using the IDE NetBeans.
*Java is case sensitive.
Syntax Errors – are prompted in an IDE since it is usually misspelled commands or
typographical errors and is easily detected by the software. If a program has a syntax error, it
will not compile.
Run time Errors – are errors occurring eventhough the program successfully compiles. In this
case, the program returns a wrong result.
*I have experienced in C programming some run time errors where my program returns garbage
values and some outputs a segmentation fault.
BufferedReader Class
- found in package, together with InputStreamReader and IOException, used for getting
Packages – contain classes that have related purpose. To put it simply, these are predefined
classes that one can use in his program which are contained in the JAVA API (Appllication
Programming Interface)
*In C, there is also an API that contains predefined classes that we can use in our programs.
JOptionPane Class
- found in javax.swing.package which makes use of dialog boxes to display messages and get
input from the user.
- It has two methods showInputDialog for getting input and showMessageDialog for displaying
Problem-Solving Skills
o Abstraction or Modelling – identifying important and unimportant characteristics and
ignoring the unimportant ones.
o Encapsulation – information hiding
o Modularity - Classes are identified to decompose/modularize problems.
Objects in Java are abstraction of real life objects. These real life objects can be effectively
represented in the programming environment through their properties(its characteristics) as data
of the program and behaviours(how it behaves) as the methods of Java. It is an
instance/example of a class.
Syntax – is mainly the structure. How you should write a command in a certain programming
Semantics – is the meaning of the command. What will the command do with your data.
Keywords are words which has some special meaning to a certain programming language and
cannot be used as identifiers.
Identifiers are names a programmer used to represent methods, variables and classes. They
are case-sensitive, and must not start nor contain special characters except from ‘/’ and ‘$’.
Classes’ names must always start with a capital letter while variables’ and methods’ names
must start with lowercase letters. It is also preferred to not start identifiers with ‘_’ or ‘$’.
Statements – are lines of the commands you want the computer to do. It always ends in a ‘;’ and
usually a single line in an editor contains a sing statements.
Block – is a way of grouping your statements inside ‘{’ ‘}’. Statements inside a block are
preferably indented of three spaces from the previous line.
Classes are templates of an object in Java and it being a template it promotes reusability.
Classes are shared by objects which are in common in attributes(specify data types),
methods(specify operations) and semantics.
Classes can be identified by paying attention to nouns. All classes are nouns but not all nouns
are classes. Be careful not to interchange some nouns which are actually attributes with
One class equals one java file and the filename must always be the same as the name of the
public class. More importantly, it would be a lot of help for a programmer if the class’ name
makes sense.
Java files always ends in .java. In addition, it helps a lot (for reusability purposes) if you can
write comments in your classes which indicates what does that specific class does.
How to document your class:
C++ style:
//comment here
C style:
/* comment here */
/** comment here */
Testing a Java Class determines if we can instantiate objects in that class. A ‘new’ operator is
used to instantiate objects. Constructor is also used as a place wg\here all initializations are
placed. If a class does not declare any constructors, a default constructor is created with no