CSE 14 Lecture Notes - Lecture 2: Tab Key, Dollar Sign

48 views5 pages
21 May 2018
School
Course
Professor
CMPS12A Lecture 2 Introduction to Java
Java is a nice high-level programming language to be able to write computer instructions using
English-based commands. It is considered high-level since it is easily readable and writeable to
us humans.
The way to start a simple Java program would need to be like this:
Example:
class HelloWorld {
indent 3-5 spaces
}
It can also be written in this form:
Example:
class
HelloWorld
{
…}
So, we always have to name the class of the program, which in this case we named it
HelloWorld. It can be anything you want but it would be easier to name it something similar to
the code you are doing. So, we always have to write -> class <name class> {
with the open brackets here and the closed brackets at the end of the program. This means
that the atual progra you rite ill e iside the lass rakets.
Another important but basic thing to know is white space, which is basically already in the
language. These white spaces include:
spaces, tabs, and new lines
Nothing much here to worry about, just that there will always be white spaces in your code.
Your code will automatically line up using the tab key depending on where you put the code
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 5 pages and 3 million more documents.

Already have an account? Log in
inside brackets. These brackets will always need to be implemented when making functions,
which we will get on to a bit later.
Comments are very essential to make your code easily readable and you can put them
anywhere in your program without affecting how the code runs. Here are two ways:
One line comment -> //
Multiple line comment -> /* */
Example:
class HelloWorld {
//Hello, this is a one-line comment and will not affect the program
/* Hello, this is a multiple-line comment and will not affect the program
if I dot put ay atual ode etee this. */
/
}
Java has reserved words (keywords) that play a major part in Java programming. As of now:
class
public
static
void
Words that are not keywords:
main
HelloWorld
args
System.out.println
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 5 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Java is a nice high-level programming language to be able to write computer instructions using. It is considered high-level since it is easily readable and writeable to us humans. The way to start a simple java program would need to be like this: It can also be written in this form: So, we always have to name the class of the program, which in this case we named it. It can be anything you want but it would be easier to name it something similar to the code you are doing. So, we always have to write -> class { with the open brackets here and the closed brackets at the end of the program. This means that the a(cid:272)tual progra(cid:373) you (cid:449)rite (cid:449)ill (cid:271)e i(cid:374)side the (cid:862)(cid:272)lass(cid:863) (cid:271)ra(cid:272)kets. Another important but basic thing to know is white space, which is basically already in the language. These white spaces include: spaces, tabs, and new lines.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents