The document discusses Java programming concepts such as classes, methods, strings, comments, and identifiers. It provides examples of Java code that declare classes with a main method and static methods that are called from main. It explains how to write comments to document code and describes syntax rules for identifiers, keywords, and strings. The document is intended to teach programmers how to write, compile, and run basic Java programs.
This document provides an introduction to basic Java programming concepts such as programs, programming languages, compiling and running Java programs, and key elements like classes, methods, and print statements. It explains Java features like data types, variables, operators, conditional statements, and loops. Examples of simple Java programs are provided to demonstrate printing output and using strings, escape sequences, and comments.
This document is the first chapter of an introductory Java programming textbook. It introduces basic Java concepts like classes, methods, and print statements. It explains how to compile and run a simple Java program that displays "Hello, World!". It also covers Java syntax, strings, escape sequences, and how to structure algorithms procedurally using static methods.
This document discusses programming languages and Java programming. It defines programming and programming languages. It explains that programming languages can be classified by purpose and level. It also discusses compilers, interpreters, and the structure of Java programs including the main method. It provides an example "Hello World" Java program and discusses important notes about programming filenames. It describes the program development process and syntax errors versus runtime errors.
This document provides an introduction to basic Java programming concepts such as programs, programming languages, compiling and running Java programs, and Java syntax. It explains that a Java program consists of a class containing a main method with print statements. Various Java concepts are defined, such as identifiers, keywords, strings, escape sequences, and syntax errors. Examples of Java print statements and their output are provided.
This document provides an introduction to Java programming concepts including:
- Java is both a programming language and platform that is simple, architecture neutral, object-oriented, and portable.
- Java source code is written in .java files and compiled into .class files by javac before being executed by the Java Virtual Machine (JVM).
- The JVM allows Java programs to run on any platform without recompilation, providing platform independence.
- Key Java concepts covered include objects, classes, methods, variables, data types, operators, control flow, and arrays.
- Examples demonstrate how to write, compile, and run simple Java programs to illustrate these core programming concepts.
This document provides an introduction to Java applications and applets. It discusses that Java can be used to develop both standalone applications and programs designed to run in web browsers (applets). It then covers the history and development of Java, the basic characteristics and components of Java programs, and how to create a simple Java application with classes, methods, and a main method. It also introduces applets, describing them as Java programs embedded in web pages, and covers some key applet methods like init() and paint(). Finally, it provides an example of a basic applet class that draws shapes and text and the HTML required to embed an applet in a web page.
This document provides an introduction to Java programming. It discusses what computer science and programming are, and introduces basic Java concepts like classes, methods, and print statements. It also covers data types, variables, operators, and control structures that allow programmers to write algorithms and programs. The document uses examples like simple print programs and a cookie baking algorithm to demonstrate core Java programming concepts.
This document contains lecture notes on Java programming divided into 6 units. Unit 1 provides an overview of Java and covers data types, variables, arrays, operators, control statements and classes. It also discusses I/O operations like reading console input/output and files. Unit 2 covers string handling and the StringBuffer class. Unit 3 discusses packages, interfaces and exception handling. Unit 4 focuses on multithreading concepts. Unit 5 covers applets, event handling and the Abstract Window Toolkit. Unit 6 introduces Swing and JDBC. The document also includes examples of Java programs and lists lab experiments and reference books.
This document contains lecture notes on Java programming divided into 6 units. Unit 1 provides an introduction to Java including an overview of data types, variables, arrays, operators, control statements, classes and objects, and input/output. It also covers inheritance, abstract classes, and the object class. Subsequent units cover topics like string handling, packages, interfaces, exception handling, multithreading, applets, event handling, AWT, Swings, and JDBC. Examples of Java programs and potential errors are also provided.
- The document is a lab manual for an introductory Java programming course that provides instructions on installing Java, using an IDE, and writing simple Java programs.
- It explains how to create a "Hello World" Java program using BlueJ or JCreator IDEs, compile and run the program, and addresses common errors students may encounter.
- The document provides an example "Hello World" Java program and explains the key components of a basic Java class including the class definition, main method, and use of System.out.println to display output.
Intro to programing with java-lecture 1Mohamed Essam
Â
The document provides an introduction to Java programming, including definitions of Java, how Java works, and the basic structure of a Java program. It explains that Java code is compiled to bytecode that can run on any device, and discusses the typical components of a Java program, including classes, methods, and the main method where program execution begins. It also provides a simple "Hello World" example Java program to demonstrate how a basic Java file is structured.
The document provides an overview of object oriented programming with Java. It discusses the differences between C++ and Java, the fundamentals of Java programming, and tools available for Java development. Key points include:
- Java is best suited for internet applications while C++ is better for large software.
- Java supports interfaces, packages, and other features not in C++.
- The Java Development Kit (JDK) contains compilers and other tools for creating Java programs.
- Java applications are standalone programs while applets are embedded in web pages.
Software development has shifted focus from efficiency to productivity, reusability, and user-friendliness. Object-oriented programming (OOP) models objects that contain data and methods. Key OOP concepts include inheritance, where subclasses extend and modify superclass features. An integrated development environment (IDE) combines tools like editors, compilers, linkers, and debuggers. Java uses a hybrid approach of compiling to bytecode, then interpreting for platform independence. Console applications use text input/output. Graphical user interface (GUI) applications use menus and buttons. Applets run in web browsers.
1. The document discusses getting started with programming in Java, including compiling and running a simple "Hello World" Java program. It explains that a Java program is written as source code in a .java file, then compiled using the javac compiler into a .class file, which is run by the Java Virtual Machine (java).
2. It provides the code for a simple "Hello World" Java program consisting of a main method that prints the text, and explains some key aspects like class and file names.
3. It describes using the terminal to navigate directories and run the javac compiler and java programs, as well as downloading the Java Development Kit for the compiler and JVM.
This document provides an introduction to Java programming concepts such as data types, variables, operators, input/output, control flow, methods, and classes. It explains what computer science and programming are, gives examples of basic Java programs using print statements, and discusses programming fundamentals like program structure, naming conventions, comments, and static methods. Methods are introduced as a way to organize code and eliminate redundancy. Overall, the document orients the reader to fundamental Java programming concepts.
Java is a widely used programming language that is platform independent and object-oriented. It uses a virtual machine to execute bytecode, allowing programs written in Java to run on any system with a Java runtime. The key features of Java include being simple, secure, robust, portable, and having strong support for object-oriented programming concepts like classes, objects, inheritance, and interfaces. Variables in Java are declared with a specific data type and can be initialized dynamically by passing values to a class constructor at runtime.
An object is an instance of a class that encapsulates state and behavior. A class defines the common attributes and behaviors of objects. Instance variables store the state of an object, and methods define the behaviors. Methods allow classes to hide implementation details and promote code reuse through polymorphism.
Here is the sequence of println statements that will generate the given output:
System.out.println("This program prints the first lines");
System.out.println("of the song 'slots'.");
System.out.println("'She lives in a trailer'");
System.out.println("'On the o");
The document discusses the basics of object-oriented programming with Java. It covers key concepts like classes, objects, methods, and the main method. It provides examples of creating a simple "Hello World" Java program with a Main class, compiling and running the code. It also demonstrates how to create multiple objects from a class and access objects between classes.
Java was created in the early 1990s by James Gosling at Sun Microsystems. It was originally designed for use in set-top boxes, but is now used widely for both web applications and desktop applications. The key aspects of Java include its simplicity, object-oriented approach, security, robustness, portability, and distributed nature. The Java Virtual Machine (JVM) plays a central role, allowing Java programs to run on any platform that supports the JVM without needing to be recompiled. A Java program consists of classes with methods defined within, and always includes a main method that is the entry point of the program.
This document provides an introduction and overview of Java applications, including:
- A brief history of Java's development starting in 1990s.
- The objectives and topics covered include introductions, history, architecture, security and a sample program.
- Java was designed to be a platform-independent language that can create applications running on a single computer or distributed network.
The document is a lab manual for Java programming that includes 12 experiments. The first experiment involves creating a Java package with Stack and Queue classes that demonstrate LIFO and FIFO principles respectively using methods like push(), pop() and enqueue(), dequeue(). The second experiment involves designing a ComplexNumber class with constructors to perform addition, subtraction and multiplication of complex numbers.
This document provides an introduction to creating Java programs. It discusses inputs, outputs, branching, looping, and some history of Java's development. It then explains how to write the simplest possible Java program that outputs "Hello World!" to demonstrate the basic structure and syntax of a Java program.
This Contains Core Java Java Basic Notes With Examples Following Are the topics I have Included in this
1. Source Code
2. Byte Code
3. Native Code
4. Compiler
5. Interpreter
6. JIT Compiler (Just In Time Compiler)
7. JVM (Java Virtual Machine)
8. JRE (Java Runtime Environment)
9. JDK (Java Development Kit)
Java Language:-
1. Character Set
2. Data Types
3. Keywords
4. Identifiers or User Defined words
5. Variables
6. Constants
7. Literals
8. Control Statement
9. Operator
10. Array
What is the Philosophy of Statistics? (and how I was drawn to it)jemille6
Â
What is the Philosophy of Statistics? (and how I was drawn to it)
Deborah G Mayo
At Dept of Philosophy, Virginia Tech
April 30, 2025
ABSTRACT: I give an introductory discussion of two key philosophical controversies in statistics in relation to today’s "replication crisis" in science: the role of probability, and the nature of evidence, in error-prone inference. I begin with a simple principle: We don’t have evidence for a claim C if little, if anything, has been done that would have found C false (or specifically flawed), even if it is. Along the way, I’ll sprinkle in some autobiographical reflections.
Ad
More Related Content
Similar to Java Primitive Type from Long Nguyen's lecture (20)
This document provides an introduction to Java programming. It discusses what computer science and programming are, and introduces basic Java concepts like classes, methods, and print statements. It also covers data types, variables, operators, and control structures that allow programmers to write algorithms and programs. The document uses examples like simple print programs and a cookie baking algorithm to demonstrate core Java programming concepts.
This document contains lecture notes on Java programming divided into 6 units. Unit 1 provides an overview of Java and covers data types, variables, arrays, operators, control statements and classes. It also discusses I/O operations like reading console input/output and files. Unit 2 covers string handling and the StringBuffer class. Unit 3 discusses packages, interfaces and exception handling. Unit 4 focuses on multithreading concepts. Unit 5 covers applets, event handling and the Abstract Window Toolkit. Unit 6 introduces Swing and JDBC. The document also includes examples of Java programs and lists lab experiments and reference books.
This document contains lecture notes on Java programming divided into 6 units. Unit 1 provides an introduction to Java including an overview of data types, variables, arrays, operators, control statements, classes and objects, and input/output. It also covers inheritance, abstract classes, and the object class. Subsequent units cover topics like string handling, packages, interfaces, exception handling, multithreading, applets, event handling, AWT, Swings, and JDBC. Examples of Java programs and potential errors are also provided.
- The document is a lab manual for an introductory Java programming course that provides instructions on installing Java, using an IDE, and writing simple Java programs.
- It explains how to create a "Hello World" Java program using BlueJ or JCreator IDEs, compile and run the program, and addresses common errors students may encounter.
- The document provides an example "Hello World" Java program and explains the key components of a basic Java class including the class definition, main method, and use of System.out.println to display output.
Intro to programing with java-lecture 1Mohamed Essam
Â
The document provides an introduction to Java programming, including definitions of Java, how Java works, and the basic structure of a Java program. It explains that Java code is compiled to bytecode that can run on any device, and discusses the typical components of a Java program, including classes, methods, and the main method where program execution begins. It also provides a simple "Hello World" example Java program to demonstrate how a basic Java file is structured.
The document provides an overview of object oriented programming with Java. It discusses the differences between C++ and Java, the fundamentals of Java programming, and tools available for Java development. Key points include:
- Java is best suited for internet applications while C++ is better for large software.
- Java supports interfaces, packages, and other features not in C++.
- The Java Development Kit (JDK) contains compilers and other tools for creating Java programs.
- Java applications are standalone programs while applets are embedded in web pages.
Software development has shifted focus from efficiency to productivity, reusability, and user-friendliness. Object-oriented programming (OOP) models objects that contain data and methods. Key OOP concepts include inheritance, where subclasses extend and modify superclass features. An integrated development environment (IDE) combines tools like editors, compilers, linkers, and debuggers. Java uses a hybrid approach of compiling to bytecode, then interpreting for platform independence. Console applications use text input/output. Graphical user interface (GUI) applications use menus and buttons. Applets run in web browsers.
1. The document discusses getting started with programming in Java, including compiling and running a simple "Hello World" Java program. It explains that a Java program is written as source code in a .java file, then compiled using the javac compiler into a .class file, which is run by the Java Virtual Machine (java).
2. It provides the code for a simple "Hello World" Java program consisting of a main method that prints the text, and explains some key aspects like class and file names.
3. It describes using the terminal to navigate directories and run the javac compiler and java programs, as well as downloading the Java Development Kit for the compiler and JVM.
This document provides an introduction to Java programming concepts such as data types, variables, operators, input/output, control flow, methods, and classes. It explains what computer science and programming are, gives examples of basic Java programs using print statements, and discusses programming fundamentals like program structure, naming conventions, comments, and static methods. Methods are introduced as a way to organize code and eliminate redundancy. Overall, the document orients the reader to fundamental Java programming concepts.
Java is a widely used programming language that is platform independent and object-oriented. It uses a virtual machine to execute bytecode, allowing programs written in Java to run on any system with a Java runtime. The key features of Java include being simple, secure, robust, portable, and having strong support for object-oriented programming concepts like classes, objects, inheritance, and interfaces. Variables in Java are declared with a specific data type and can be initialized dynamically by passing values to a class constructor at runtime.
An object is an instance of a class that encapsulates state and behavior. A class defines the common attributes and behaviors of objects. Instance variables store the state of an object, and methods define the behaviors. Methods allow classes to hide implementation details and promote code reuse through polymorphism.
Here is the sequence of println statements that will generate the given output:
System.out.println("This program prints the first lines");
System.out.println("of the song 'slots'.");
System.out.println("'She lives in a trailer'");
System.out.println("'On the o");
The document discusses the basics of object-oriented programming with Java. It covers key concepts like classes, objects, methods, and the main method. It provides examples of creating a simple "Hello World" Java program with a Main class, compiling and running the code. It also demonstrates how to create multiple objects from a class and access objects between classes.
Java was created in the early 1990s by James Gosling at Sun Microsystems. It was originally designed for use in set-top boxes, but is now used widely for both web applications and desktop applications. The key aspects of Java include its simplicity, object-oriented approach, security, robustness, portability, and distributed nature. The Java Virtual Machine (JVM) plays a central role, allowing Java programs to run on any platform that supports the JVM without needing to be recompiled. A Java program consists of classes with methods defined within, and always includes a main method that is the entry point of the program.
This document provides an introduction and overview of Java applications, including:
- A brief history of Java's development starting in 1990s.
- The objectives and topics covered include introductions, history, architecture, security and a sample program.
- Java was designed to be a platform-independent language that can create applications running on a single computer or distributed network.
The document is a lab manual for Java programming that includes 12 experiments. The first experiment involves creating a Java package with Stack and Queue classes that demonstrate LIFO and FIFO principles respectively using methods like push(), pop() and enqueue(), dequeue(). The second experiment involves designing a ComplexNumber class with constructors to perform addition, subtraction and multiplication of complex numbers.
This document provides an introduction to creating Java programs. It discusses inputs, outputs, branching, looping, and some history of Java's development. It then explains how to write the simplest possible Java program that outputs "Hello World!" to demonstrate the basic structure and syntax of a Java program.
This Contains Core Java Java Basic Notes With Examples Following Are the topics I have Included in this
1. Source Code
2. Byte Code
3. Native Code
4. Compiler
5. Interpreter
6. JIT Compiler (Just In Time Compiler)
7. JVM (Java Virtual Machine)
8. JRE (Java Runtime Environment)
9. JDK (Java Development Kit)
Java Language:-
1. Character Set
2. Data Types
3. Keywords
4. Identifiers or User Defined words
5. Variables
6. Constants
7. Literals
8. Control Statement
9. Operator
10. Array
What is the Philosophy of Statistics? (and how I was drawn to it)jemille6
Â
What is the Philosophy of Statistics? (and how I was drawn to it)
Deborah G Mayo
At Dept of Philosophy, Virginia Tech
April 30, 2025
ABSTRACT: I give an introductory discussion of two key philosophical controversies in statistics in relation to today’s "replication crisis" in science: the role of probability, and the nature of evidence, in error-prone inference. I begin with a simple principle: We don’t have evidence for a claim C if little, if anything, has been done that would have found C false (or specifically flawed), even if it is. Along the way, I’ll sprinkle in some autobiographical reflections.
How to Manage Amounts in Local Currency in Odoo 18 PurchaseCeline George
Â
In this slide, we’ll discuss on how to manage amounts in local currency in Odoo 18 Purchase. Odoo 18 allows us to manage purchase orders and invoices in our local currency.
Ancient Stone Sculptures of India: As a Source of Indian HistoryVirag Sontakke
Â
This Presentation is prepared for Graduate Students. A presentation that provides basic information about the topic. Students should seek further information from the recommended books and articles. This presentation is only for students and purely for academic purposes. I took/copied the pictures/maps included in the presentation are from the internet. The presenter is thankful to them and herewith courtesy is given to all. This presentation is only for academic purposes.
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...parmarjuli1412
Â
Mental Health Assessment in 5th semester Bsc. nursing and also used in 2nd year GNM nursing. in included introduction, definition, purpose, methods of psychiatric assessment, history taking, mental status examination, psychological test and psychiatric investigation
Happy May and Happy Weekend, My Guest Students.
Weekends seem more popular for Workshop Class Days lol.
These Presentations are timeless. Tune in anytime, any weekend.
<<I am Adult EDU Vocational, Ordained, Certified and Experienced. Course genres are personal development for holistic health, healing, and self care. I am also skilled in Health Sciences. However; I am not coaching at this time.>>
A 5th FREE WORKSHOP/ Daily Living.
Our Sponsor / Learning On Alison:
Sponsor: Learning On Alison:
— We believe that empowering yourself shouldn’t just be rewarding, but also really simple (and free). That’s why your journey from clicking on a course you want to take to completing it and getting a certificate takes only 6 steps.
Hopefully Before Summer, We can add our courses to the teacher/creator section. It's all within project management and preps right now. So wish us luck.
Check our Website for more info: https://ldmchapels.weebly.com
Get started for Free.
​
​Currency is Euro. Courses can be free unlimited. Only pay for your diploma. See Website for xtra assistance.
​Make sure to convert your cash. Online Wallets do vary. I keep my transactions safe as possible. I do prefer PayPal Biz. (See Site for more info.)
Understanding Vibrations
If not experienced, it may seem weird understanding vibes? We start small and by accident. Usually, we learn about vibrations within social. Examples are: That bad vibe you felt. Also, that good feeling you had. These are common situations we often have naturally. We chit chat about it then let it go. However; those are called vibes using your instincts. Then, your senses are called your intuition. We all can develop the gift of intuition and using energy awareness.
Energy Healing
First, Energy healing is universal. This is also true for Reiki as an art and rehab resource. Within the Health Sciences, Rehab has changed dramatically. The term is now very flexible.
Reiki alone, expanded tremendously during the past 3 years. Distant healing is almost more popular than one-on-one sessions? It’s not a replacement by all means. However, its now easier access online vs local sessions. This does break limit barriers providing instant comfort.
Practice Poses
You can stand within mountain pose Tadasana to get started.
Also, you can start within a lotus Sitting Position to begin a session.
There’s no wrong or right way. Maybe if you are rushing, that’s incorrect lol. The key is being comfortable, calm, at peace. This begins any session.
Also using props like candles, incenses, even going outdoors for fresh air.
(See Presentation for all sections, THX)
Clearing Karma, Letting go.
Now, that you understand more about energies, vibrations, the practice fusions, let’s go deeper. I wanted to make sure you all were comfortable. These sessions are for all levels from beginner to review.
Again See the presentation slides, Thx.
Struggling with your botany assignments? This comprehensive guide is designed to support college students in mastering key concepts of plant biology. Whether you're dealing with plant anatomy, physiology, ecology, or taxonomy, this guide offers helpful explanations, study tips, and insights into how assignment help services can make learning more effective and stress-free.
📌What's Inside:
• Introduction to Botany
• Core Topics covered
• Common Student Challenges
• Tips for Excelling in Botany Assignments
• Benefits of Tutoring and Academic Support
• Conclusion and Next Steps
Perfect for biology students looking for academic support, this guide is a useful resource for improving grades and building a strong understanding of botany.
WhatsApp:- +91-9878492406
Email:- [email protected]
Website:- https://onlinecollegehomeworkhelp.com/botany-homework-help
Slides to support presentations and the publication of my book Well-Being and Creative Careers: What Makes You Happy Can Also Make You Sick, out in September 2025 with Intellect Books in the UK and worldwide, distributed in the US by The University of Chicago Press.
In this book and presentation, I investigate the systemic issues that make creative work both exhilarating and unsustainable. Drawing on extensive research and in-depth interviews with media professionals, the hidden downsides of doing what you love get documented, analyzing how workplace structures, high workloads, and perceived injustices contribute to mental and physical distress.
All of this is not just about what’s broken; it’s about what can be done. The talk concludes with providing a roadmap for rethinking the culture of creative industries and offers strategies for balancing passion with sustainability.
With this book and presentation I hope to challenge us to imagine a healthier future for the labor of love that a creative career is.
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabanifruinkamel7m
Â
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
How to Configure Public Holidays & Mandatory Days in Odoo 18Celine George
Â
In this slide, we’ll explore the steps to set up and manage Public Holidays and Mandatory Days in Odoo 18 effectively. Managing Public Holidays and Mandatory Days is essential for maintaining an organized and compliant work schedule in any organization.
How to Share Accounts Between Companies in Odoo 18Celine George
Â
In this slide we’ll discuss on how to share Accounts between companies in odoo 18. Sharing accounts between companies in Odoo is a feature that can be beneficial in certain scenarios, particularly when dealing with Consolidated Financial Reporting, Shared Services, Intercompany Transactions etc.
How to Create Kanban View in Odoo 18 - Odoo SlidesCeline George
Â
The Kanban view in Odoo is a visual interface that organizes records into cards across columns, representing different stages of a process. It is used to manage tasks, workflows, or any categorized data, allowing users to easily track progress by moving cards between stages.
How to Create Kanban View in Odoo 18 - Odoo SlidesCeline George
Â
Ad
Java Primitive Type from Long Nguyen's lecture
1. Unit 1: Primitive Types
Basic Java Syntax
Adapted from:
1) Building Java Programs: A Back to Basics Approach
by Stuart Reges and Marty Stepp
2) Runestone CSAwesome Curriculum
https://longbaonguyen.github.io
This work is licensed under the
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
2. 2
Java
What do Minecraft, Android phones, and Netflix have in
common? They’re all programmed in Java!
Many of the apps you use in an Android phone or tablet are also
written in Java. Netflix uses Java for some of its software too.
Java is used worldwide to create software that we all use.
3. 3
Java
Java is a programming language, which means that we can
use Java to tell a computer what to do.
Computers don’t actually speak Java so we have
to compile (translate) Java source files (they end in .java) into
class files (they end in .class).
The source file is something humans can read and edit, and the
class file is code that a computer can understand and can run.
4. 4
Java Terminology
All Java code are organized into units called classes.
class:
(a) A module or program that can contain executable
code.
(b) A description of a type of objects. (Animal class,
Human class, Employee class, Car class)
statement: An executable piece of code that represents a
complete command to the computer.
– every basic Java statement ends with a semicolon ;
method: A named sequence of statements that can be executed
together to perform a particular action or computation.
5. 5
Structure of a Java program
public class name {
public static void main(String[] args) {
statement;
statement;
...
statement;
}
}
• Every executable Java program consists of a class, called the
driver class,
– that contains a method named main,
• that contains the statements (commands) to be executed.
class: a program
statement: a command to be executed
method: a named group
of statements
6. 6
Program Template
Here's a simple program that prints out a message on the screen. Code
highlighted in red should be in every program!
public class Main{
public static void main(String[] args){
System.out.println("Hello, World!");
}
}
Output:
Hello, World!
7. 7
First Program: repl.it
We will use repl.it, an online integrated development
environment(IDE), for the first part of this course to write all of
our code.
console: Text box into which
the program's output is printed.
Click on “run” to compile and
run your code!
8. 8
File naming
The name of the class has to match up with the name of the file.
For example, the class below is called Main therefore the name
of the file is Main.java. On replit, the main class must be called
Main.java.(in other IDEs, you can pick any name.)
9. 9
Printing
Two ways to print a line of output on the console:
System.out.println() and System.out.print().
System.out.println() is just the way that you ask Java to
print out the value of something followed by a new line (ln).
System.out.print() without the ln will print out something
without advancing to the next new line.
10. 10
System.out.println
public class Welcome{
public static void main(String[] args){
System.out.println("Hi there!");
System.out.println(”Welcome to APCS A!");
}
}
Output:
Hi There!
Welcome to APCS A!
The “System” in System.out.println() must be capitalized. And
the command line must end with a semicolon (;).
11. 11
System.out.print
public class SecondClass{
public static void main(String[] args){
System.out.print("Hi there!");
System.out.println(”Welcome to APCS A!");
System.out.print(”We will learn Java!");
}
}
Output:
Hi There!Welcome to APCS A!
We will learn Java!
Do you see why there are two lines of output as above?
12. 12
Find the errors.
pooblic class Errors
public static void main(String args){
System.out.print("Good morning! ")
system.out.print("Good afternoon!);
System.Print "And good evening!";
}
See next slide for all of the corrections.
13. 13
Corrected!
public class Errors {
public static void main(String[] args){
System.out.print("Good morning! ");
System.out.print("Good afternoon!”);
System.out.print("And good evening!”);
}
}
14. 14
Strings
• string: A sequence of characters to be printed.
– Starts and ends with a " quote " character.
• The quotes do not appear in the output.
– Examples:
"hello"
"This is a string. It's very long!"
• Restrictions:
– May not span multiple lines.
"This is not
a legal String."
– May not contain a " character.
"This is not a "legal" String either."
A string enclosed in quotes
is called a string literal.
15. 15
Comments
• comment: A note written in source code by the programmer
to describe or clarify the code.
– Comments are not executed when your program runs.
• Syntax:
// comment text, on one line
or,
/* comment text; may span multiple lines */
• Examples:
// This is a one-line comment.
/* This is a very long
multi-line
comment. */
16. 16
Using comments
• Where to place comments:
– at the top of each file (a "comment header")
– at the start of every method (seen later)
– to explain complex pieces of code
• Comments are useful for:
– Understanding larger, more complex programs.
– Multiple programmers working together, who must understand
each other's code.
17. 17
Comments example
/* Suzy Student, CS 101, Fall 2019
This program prints lyrics about ... something. */
public class BaWitDaBa {
public static void main(String[] args) {
// first verse
System.out.println("Bawitdaba");
System.out.println("da bang a dang diggy diggy");
System.out.println();
// second verse
System.out.println("diggy said the boogy");
System.out.println("said up jump the boogy");
}
}
18. 18
Indent Nicely!
public class Welcome{ public static void main(String[]
args){ System.out.println("Hi there!”
);System.out.println(”Welcome to APCS A!");}}
The code above will compile and run correctly. Java ignore whitespaces.
But it is very hard to read, please make an effort to indent nicely!
public class Welcome{
public static void main(String[] args){
System.out.println("Hi there!");
System.out.println(”Welcome to APCS A!");
}
}
19. 19
Lab 1
Create a new repl on your repl.it account and write a program
that has the following outputs:
You must use exactly 5 different print statements.(println and/or
print).
Output:
I am Sam. Sam I am. I do not like them, Sam-I-am.
I do not like green eggs and ham.
20. 20
References
For more tutorials/lecture notes in Java, Python, game
programming, artificial intelligence with neural networks:
https://longbaonguyen.github.io
1) Building Java Programs: A Back to Basics Approach by Stuart Reges and
Marty Stepp
2) Runestone CSAwesome Curriculum:
https://runestone.academy/runestone/books/published/csawesome/index.html