Introduction to Java

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Advantages of Java?

-free -platform-independent at both development level and runtime level -can be written in any environment (ex. Mac, Linux) -can be run in most current web browsers relatively simple language

How to add space around items?

...

What is java?

object oriented programming language all programs are created by manipulating "objects" to perform the functions required by the program Ex. in Call of Duty, the people, gun, and bullets are all objects and the program is based off these objects interacting with each other (ie. gun fires bullet)

What is the sample "hello world" code?

public class HelloWorld { public static void main(String[]args) { System.out.println("Hello World!") } }

Types of Java programs?

1)Applications •Mean to be run with a command line (ex. MS-DOS) •All files must exist locally on the computer •If you want a GUI, the program must contain code to create window •Require access to "standard input" (keyboard) and "standard output" (monitor) 2)Applet •A Java program which is embedded as part of the web page •Files are located within the web page •GUI drawing surface provided on web page

What are the 3 pieces of software required to create a program?

1.Integrated Development Environment (IDE) oa program used to write the Java code 2.A Compiler oa program that converts the end written in the IDE into byte code 3.A Java Virtual Machine Interpreter (JVM) oConverts the byte code into machine code that can be run by the computer

What are the 2 major sections of a Java application?

1.The Class oContains all the code for this particular program 2.The Main Method oContains the code that will be run first when the program is started oLocated inside the class oEx. "First Program (Main Method)"

In order to create a working program in java you need

1.Write the Java source code (.java file) 2.Compile the source code to a binary file, called byte code (.class file) 3.Run the Java program using an interpreter (an application that implements the (JVM)

How do you ouput/create a console?

• To make program output look nicer, we can use a library from people who created the Ready to Program IDE • To do this, we must add the Ready "hsa" library to Dr. Java • The code we require is found in the Console class • In order to use this code, you must first import the code into your program: import hsa.Console; import java.awt.*; • Once the code has been imported, you need to create a console to display the output: static Console c; c = new Console ( ) • You can name your Console anything you like (although c is the most common name)

Outputting Text?

•There are several commands (called methods) that can be used to output onto a Console •In order to display text, you must use the print and println methods •You use the print method if you wish to remain on the same line after output •The println method sets the cursor on the next line after the output


Kaugnay na mga set ng pag-aaral

International Business Chapter 5-8

View Set

NWS Cha 7: Virtualization and Cloud Computing

View Set

FUNDIES II: Chapter 39- Oxygen and Perfusion

View Set

Pennsylvania Property and Casualty Insurance Examination

View Set

Identifying Claims of Fact, Value, and Policy

View Set

The Princess Bride Memorable Quotes

View Set

ap bio quiz 5.3 mendelian genetics

View Set