© A+ Computer Science - www.apluscompsci.com. public class CompSci { } All Java programs start with a class.

Slides:



Advertisements
Similar presentations
Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
Advertisements

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.
IT151: Introduction to Programming
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
© 2007 Lawrenceville Press Slide 1 Chapter 3 Classes and Objects.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
Your First Java Program: HelloWorld.java
© A+ Computer Science - public class CompSci { } All Java programs start with a class.
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter2: Introduction to Java Applications 1.
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,
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
COMP 110 Errors, Strings, and Review Tabitha Peck M.S. January 28, 2008 MWF 3-3:50 pm Philips
Writing Methods. Create the method Methods, like functions, do something They contain the code that performs the job Methods have two parts.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
“Introduction to Programming With Java”
2.2 Information on Program Appearance and Printing.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
JAVA BASICS: Variables and References SYNTAX, ERRORS, AND DEBUGGING.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
3 Major Steps for Creating/Running a Java Program You write the source code for the program and save it as a.java file. You compile the.java program using.
Java Syntax and Output Java Part 3. public class CompSci { } All Java programs start with a class.
Chapter 2: Java Fundamentals
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
8/31: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) public static void main(String[]
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
CSC Programming I Lecture 6 September 4, 2002.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
ECE 122 Feb. 1, Introduction to Eclipse Java Statements Declaration Assignment Method calls.
Chapter 3 Introduction To Java. OBJECTIVES Packages & Libraries Statements Comments Bytecode, compiler, interpreter Outputting print() & println() Formatting.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
Lab 01-2 Objectives:  Writing a Java program.  How to send output to the command line console.  Learn about escape sequences.  Learn how to compile,
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Java FilesOops - Mistake Java lingoSyntax
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
1 Review for exam 1 CS 101 Aaron Bloomfield. 2 Today’s lecture An overview of the “review” sections of chapters 1-3 Stop me if you want me to go over.
1 Data and Expressions Chapter 2 In PowerPoint, click on the speaker icon then the “play” button to hear audio narration.
© A+ Computer Science - public class CompSci { } All Java programs start with a class.
© 2007 Lawrenceville Press Slide 1 Chapter 3 Classes and Objects 1. How is a class different from an object?
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
Catie Welsh January 31,  Project 1 Due Wednesday  Lab 1 Grades are posted 2.
CSC 110 – Intro to Computing - Programming
1/16: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
Review for exam 1 CS 101 Aaron Bloomfield. 2 Today’s lecture An overview of the “review” sections of chapters 1- 3 and 5 Stop me if you want me to go.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Computer Programming Your First Java Program: HelloWorld.java.
Chapter 1 Introduction to Computers, Programs, and Java
GC101 Introduction to computer and program
Chapter 2, Part I Introduction to C Programming
CSE 190D, Winter 2013 Building Java Programs Chapter 1
Intro to Java.
Writing Methods.
Programming Vocabulary.
Chapter 3 Classes and Objects
Java Intro.
Anatomy of a Java Program
© A+ Computer Science - Basic Java © A+ Computer Science -
How to Run a Java Program
Presentation transcript:

© A+ Computer Science -

public class CompSci { } All Java programs start with a class.

© A+ Computer Science - public class CompSci { public static void main(String[] args) { System.out.println("Comp Sci!"); } OUTPUT Comp Sci!

© A+ Computer Science - public class CompSci { //open brace public static void main(String[] args) { System.out.println("Comp Sci!"); } } //close brace Braces – You gotta have ‘em! Every class and every method must have a { and a }.

© A+ Computer Science - public class CompSci { public static void main(String[] args) { System.out.println("Comp Sci!"); } You must put a semi-colon at the end of all Java program statements ( ; ).

© A+ Computer Science - Never put a ; before an open { brace ;{ //illegal }; //legal

© A+ Computer Science - public class CompSci { public static void main(String[] args) { System.out.println("Comp Sci!"); } Indent all code 3 spaces to make it easier to read.

© A+ Computer Science -

System.out frequently used methods NameUse print(x)print x and stay on the current line println(x)print x and move to next line down printf(s,x)print x according to s specifications

© A+ Computer Science - System.out.print( " compsci"); referencecommand / method OUTPUT compsci

© A+ Computer Science - System.out.print("compsci"); OUTPUT compscicompsci

© A+ Computer Science - System.out.println("compsci"); OUTPUT compsci

© A+ Computer Science - System.out.println("compsci"); OUTPUTcompsci

© A+ Computer Science -

System.out.println("c\tompsci " ); \nnewline \ttab \rcarriage return \bbackspace OUTPUT c ompsci

© A+ Computer Science - System.out.println("com\tpsci " ); OUTPUT com psci \nnewline \ttab \rcarriage return \bbackspace

© A+ Computer Science - System.out.println("comp\nsci"); OUTPUT comp sci \nnewline \ttab \rcarriage return \bbackspace

© A+ Computer Science -

\\outs \ \"outs " \’outs ’ System.out.println( " \\compsci\ " / " ); OUTPUT \compsci"/

© A+ Computer Science - \\outs \ \"outs " \’outs ’ System.out.println("\\'comp\'sci\'/"); OUTPUT \'comp'sci'/

© A+ Computer Science - Escape Sequences frequently used combinations NameUse \ttabs over five spaces \nmoves to front of next line \bdeletes previous character \rmoves to front of current line \\nets one backslash \ \"nets one double quote " \’nets one single quote ’

© A+ Computer Science - //single-line comments /* */block comments //this line prints stuff on the screen System.out.println("stuff");

© A+ Computer Science - //single-line comments /* */block comments /* this line prints stuff on the screen */ System.out.println("stuff");

© A+ Computer Science - System.out.printf("%s","compsci\n"); OUTPUT compsci

© A+ Computer Science -

Syntax errors occur when you type something in wrong, causing the code to not compile. //missing semicolon - ; expected System.out.println("stuff") //case problem – should be System system.out.println("stuff")

© A+ Computer Science - Runtime errors occur when something goes wrong while the program is running. //an out of bounds exception is thrown String s = "runtime_error"; System.out.println( s.charAt(15) );

© A+ Computer Science -