Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()

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. 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.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
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
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.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
Unit 2: Java Introduction to Programming 2.1 Initial Example.
“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.
Comments are for people Header comments supply basic information about the artifact.
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
Welcome to the Lecture Series on “Introduction to Programming With Java”
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Java Syntax and Output Java Part 3. public class CompSci { } All Java programs start with a class.
Chapter 2: Java Fundamentals
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
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:
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Can we talk?. In Hello World we already saw how to do Standard Output. You simply use the command line System.out.println(“text”); There are different.
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 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.
Getting Started.
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.
Introduction to Computing Concepts Note Set 12. Writing a Program from Scratch public class SampleProgram1 { public static void main (String [] args)
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,
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
Chapter 2 print / println String Literals Escape Characters Variables / data types.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
1 Data and Expressions Chapter 2 In PowerPoint, click on the speaker icon then the “play” button to hear audio narration.
© 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.
Simple Console Output. What we will briefly discuss System.out.println( … ) System.out.print( … ) System.out.printf( … )
CSC 110 – Intro to Computing - Programming
Chapter 2 1.What is the difference between print / println 2.What are String Literals 3.What are the Escape Characters for backslash, double quotataions,
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:
Introducing Java Chapter 3. Why Program in Java? 0 Java was developed by Sun Microsystems. It is a widely used high-level programming language. 0 One.
Lecture 4 – Scanner & Style
Introduction to programming in java
Computer Programming Your First Java Program: HelloWorld.java.
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 2, Part I Introduction to C Programming
CSE 190D, Winter 2013 Building Java Programs Chapter 1
Intro to Java.
Chapter 3 Classes and Objects
Java Tutotrial for [NLP-AI] 2
Java Intro.
Chapter 2 Create a Chapter 2 Workspace Create a Project called Notes
Anatomy of a Java Program
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.
CSE 142, Spring 2012 Building Java Programs Chapter 1
CSE 142, Winter 2014 Building Java Programs Chapter 1
© A+ Computer Science - Basic Java © A+ Computer Science -
Presentation transcript:

Introduction to Java Thanks to Dan Lunney (SHS)

Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format() method Conventions

File Names In JCreator the file name and class name must be identical Always start class names with a capital letter If more than one word in file name all names are capitalized Always begin java programs with: public class FileName { Code goes here… }

The “main” method Executes the main section of code All other methods “called” from here Syntax for main method is: public static void main(String[] args) { code in here… }

Output to Screen To print to screen we use the line: System.out.println(); What ever is in the () will print Text must be in “” marks There are two options –println – prints a line and the enters to start new line –print – prints line and remains on same line Example: System.out.println(“Hello class”); prints Hello class on the screen

Escape Sequence – Special Characters By including special characters within the quote marks, java will perform special formatting \n – new line \t – tab (8 spaces) \\ - backslash \” – double quote mark Example: System.out.print(“Hello\t”); System.out.print(“class”); prints Hello class

format() method Can format the look of text Example: System.out.format(“%-10s %-8s”, “Hello”, “class”); Prints – Hello class (5 spaces between) Symbols –% - indicates start of format –“-” indicates left align (nothing for right align) – # indicates how many spaces for text –S indicates it’s a string

Java Conventions Always use in an introductory comment with name, date, and project All class names start with Upper case letters Comments should be included before all methods to explain them All code statements should be indented from method line Place starting curly brace { on the same line as classes and methods. Place the ending curly brace } on its own line with nothing else.