Computer Programming: Java - Week 01 Notes
Introduction to Computer Programming with Java
Hardware vs. Software
- Hardware: Physical electronic devices.
- Examples: phone, computer components.
- Software: Instructions that tell hardware what to do.
- Examples: apps on a phone.
Integrated Development Environments (IDEs)
- Using an IDE to write software.
- Example IDE: Eclipse.
- Choice of IDE is flexible (NetBeans, Dr. Java, etc.).
Types of Programming Languages
- Low-Level Languages:
- Directly understood by the computer.
- Difficult to read and write.
- Require many instructions for simple tasks.
- High-Level Languages:
- Easier to read and write.
- Fewer commands accomplish more.
- Example: Java (
System.out.println(“Hi”);)
Java Code Structure
- Java code is stored in files.
.javafiles: Contain the Java code you write..classfiles: Contain translated Java code that the computer understands.
- Java code is organized into projects.
Basic Java Program Structure
All Java programs must follow a specific structure:
public class ClassName { public static void main(String[ ] args) { // Your program goes here } }The class name should match the file name (without the
.javaextension).- Example:
HelloWorld.java
- Example:
Variables
- Definition: A named location in memory that stores a value.
- Analogy: Like 'x' in the function .
- If , then to evaluate , we store 1 in 'x'.
- In Java, variables can hold numbers, words, and other types of data.
- Examples:
String myFirstVariable;int mySecondVariable;
Variable Naming Conventions
- Good Examples:
agefirstNamenumberOfClasseshourfred
- Bad Examples:
FirstNamefirstnameVariablePractice.java
Common Errors with Variables
String firstName = Joe;- Error: Missing quotes around
Joe. Should be `String firstName =
- Error: Missing quotes around