Debugging Exercise 00 Try compiling the code samples.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
Java Applets A First Program. Applet Example /* The world’s simplest program, repeated once more in another format in an attempt to turn all of you into.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
Chapter 2: Java Fundamentals Java Program Structure.
Developing User Interfaces (DUI) Chris North cs3724: HCI.
“Introduction to Programming With Java”
Introduction to Java Programming CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University.
Introduction to Java Programming CS 21a: Introduction to Computing I First Semester,
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
FRST JAVA PROGRAM. Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications.
Introduction to Java and Object-Oriented Programming AJSS Computer Camp Department of Information Systems and Computer Science Ateneo de Manila University.
Lesson 36: The calculator – Java Applets. 1. Creating Your First Applet HelloWorldApp is an example of a Java application, a standalone program. Now you.
Clement Allen, PhD Florida A&M University SUMMER 2006.
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
The scope of local variables. Murphy's Law The famous Murphy's Law says: Anything that can possibly go wrong, does. (Wikipedia page on Murphy's Law:
Introduction to Java Applets Sangeetha Parthasarathy 05/21/2001.
Intro to Applets August 19, 2008 Mrs. C. Furman. Java Applets vs. Java Applications Java Applet: a program that is intended for use on the web. Java Applet:
Applets. What is an applet? Why create applets instead of applications? – Applets are Java programs that can be embedded in an HTML document – In contrast,
习 题 4.23 编写一个 applet ,读取一个矩形的边长,然后 用在 paint 方法中使用 drawString 方法画出用星组成 的空心矩形。程序应能画出边长从 1 到 20 的任何矩 形。
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
2/4: Objects & Java Applets Objects: their nature –attributes & behaviors –inheritance Java Applets –what is an applet vs. an application? –where do applets.
The Drawing program – Java Applets
BUILDING JAVA PROGRAMS CHAPTER 1 ERRORS. 22 OBJECTIVES Recognize different errors that Java uses and how to fix them.
Mixing integer and floating point numbers in an arithmetic operation.
Creating Your First Computer Program in Java Margaret Yau.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
The assignment expressions. The assignment operator in an assignment statement We have seen the assignment statement: Effect: var = expr; Stores the value.
1 Applets. 2 Design of Applets 3 Sun wrote Java to be executable within a hosting application browser The applications are applets. An applet is downloaded.
Introduction to Programming. The Programming Process Create/Edit Program Compile Program Execute Program Compile Errors?Run-Time Errors? Source Program.
Variables and Methods Chapter 3 – Lecture Slides.
Java Swing One of the most important features of Java is its ability to draw graphics.
First Programs Chapter 2 The Java language (compiler) on CD ROM Create a program using an editor Compile the program Run the program Integrated Development.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.3 Write Your First Java Program Produced by Harvey.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
2/4: Objects & Java Applets Objects: their nature –attributes & behaviors –inheritance –information hiding –classes: blueprints for objects Java Applets.
Computer Science 209 Software Development Packages.
Import javax.swing.*; class Check { public static void main(String[] args) { JFrame frame = new JFrame("Check"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//DO_NOTHING_ON_CLOSE.
Introduction to programming in java
Computer Programming Your First Java Program: HelloWorld.java.
User Interface Programming In Java
Exercise Java programming
Compiling and Running a Java Program
Introduction to.
Maha AlSaif Maryam AlQattan
Code Magnets problem for wk5
UNIT-5.
Exercise 11.1 Write a code fragment that performs the same function as the statement below without using the crash method Toolbox.crash(amount < 0,
AP Java Warm-up Boolean Array.
Java Intro.
CS110D Programming Language I
CS 180 Assignment 6 Arrays.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Applet 2019/4/23.
Chapter 2: Java Fundamentals
Introductory Java Programming
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
CSS161: Fundamentals of Computing
A Brief History January 1996: first official release JDK 1.0
Presentation transcript:

Debugging Exercise 00 Try compiling the code samples. Examine the errors reported by the compiler. Try to figure out what’s really wrong.

public class Hello ( public static void main( String args[] ) System.out.println( “Hello world” ); )

public class Hello { public static void main( String args[] ) System.out.println( “Hello world” ;) }

public class Hello { public static void( String args[] ) System.out.println( “Hello world” ); }

public class Hello { public static void main( string args[] ) System.out.println( “Hello world” ); }

public class Hello { public static void main( String args[] ) System.out.printIn( “Hello world” ); }

public class Hello { public static void main( String args[] ) system.out.println( “Hello world” ); }

C:\> java Hello.java

C:\> javac Hello

import javax.swing.* import java.awt.*; public class HelloAgain extends JApplet { public void paint( Graphics g ) g.drawString( “Hello”, 50, 50 ); }

import javax.swing.*; public class HelloAgain extends JApplet { public void paint( Graphics g ) g.drawString( “Hello”, 50, 50 ); }

import javax.swing.*; import java.awt.*; public class HelloAgain extends JApplet { public void paint( Graphics g ) g.DrawString( “Hello”, 50, 50 ); }

import javax.swing.*; import java.awt.*; public class HelloAgain { public void paint( Graphics g ) g.drawString( “Hello”, 50, 50 ); }

C:\> javac HA.html