Introduction To Programming Languages
Introduction To Programming Languages
Email : [email protected]
Additional references:
Java How to Program, Eight Edition, Paul Deitel, Harvey
Deitel, Pearson.
Intro. to Programming Languages
Class rules
Attend class on time
No eating in class
Data Types
Syntax error
Misuse of language
Debugging
Freeing program of all errors
Logic errors
Also called semantic errors
Object-oriented language
General-purpose
Advantages
Security features
Architecturally neutral
Java applications
Called Java stand-alone programs
Console applications
Windowed applications
Menus
Toolbars
Dialog boxes
Analyzing a Java Application That Uses Console
Output
Arguments
Pieces of information passed to method
Method
Requires information to perform its task
Understanding the First Class
Everything used within Java program must be
part of a class
Define Java class using any name or identifier
Requirements for identifiers
Must begin with:
Letter of English alphabet
Or non-English letter (such as α or π)
Letters
Digits
Underscores
Dollar signs
Access modifier
Defines how class can be accessed
Understanding the First Class
(cont'd)
Understanding the First Class
(cont'd)
Understanding the First Class
(cont'd)
Understanding the main() Method
static
Reserved keyword
void
Use in main() method header
Compilation outcomes
javac unrecognized command
Misspelled filename
JOptionPane
Produce dialog boxes
Dialog box
GUI object resembling window
Package
Group of classes
import statement
Use to access built-in Java class
Creating a Java Application Using GUI Output
(cont’d)
import javax.swing.JOptionPane;
public class FirstDialog
{
public static void main(String[] args)
{
JOptionPane.showMessageDialog(null, "First Java dialog");
}
}
Correcting Errors and Finding Help
First line of error message displays:
Name of file where error found
Line number
Nature of error
Location
Compile-time error
Compiler detects violation of language rules
Java API
Also called the Java class library
javac
Compile command
java
Execute command
JOptionPane
GUI
Provides methods for creating dialogs