Uploaded December 2024 | Updated September 2026, 2 weeks ago
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args) {
String name = "Bro Code";
int length = name.length();
char letter = name.charAt(0);
int index = name.indexOf(" ");
int lastIndex = name.lastIndexOf("o");
name = name.toUpperCase();
name = name.toLowerCase();
name = name.trim();
name = name.replace("o", "a");
if(name.isEmpty()){
System.out.println("Your name is empty");
}
else{
System.out.println("Hello " + name);
}
if(name.contains(" ")){
System.out.println("Your name contains a space");
}
else{
System.out.println("Your name DOESN'T contain any spaces");
}
if(name.equalsIgnoreCase("password")){
System.out.println("Your name can't be password");
}
else{
System.out.println("Hello " + name);
}
}
}
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args) {
String name = "Bro Code";
int length = name.length();
char letter = name.charAt(0);
int index = name.indexOf(" ");
int lastIndex = name.lastIndexOf("o");
name = name.toUpperCase();
name = name.toLowerCase();
name = name.trim();
name = name.replace("o", "a");
if(name.isEmpty()){
System.out.println("Your name is empty");
}
else{
System.out.println("Hello " + name);
}
if(name.contains(" ")){
System.out.println("Your name contains a space");
}
else{
System.out.println("Your name DOESN'T contain any spaces");
}
if(name.equalsIgnoreCase("password")){
System.out.println("Your name can't be password");
}
else{
System.out.println("Hello " + name);
}
}
}



![Learn Java getters and setters in 10 minutes! ๐
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args) {
// They help protect object data and add rules for accessing or modifying them.
// GETTERS = Methods that make a field READABLE.
// SETTERS = Methods that make a field WRITEABLE.
Car car = new Car(Charger, Yellow, 10000);
car.setColor(Blue);
car.setPrice(5000);
System.out.println(car.getColor() + + car.getModel() + + car.getPrice());
}
}
public class Car {
private String model;
private String color;
private int price;
Car(String model, String color, int price){
this.model = model;
this.color = color;
this.price = price;
}
String getModel(){
return this.model;
}
String getColor(){
return this.color;
}
String getPrice(){
return $ + this.price;
}
void setColor(String color){
this.color = color;
}
void setPrice(int price){
this.price = price;
}
} Learn Java getters and setters in 10 minutes! ๐](https://i.ytimg.com/vi/OjrR_C_UPjc/mqdefault.jpg)

![Code a simple java shopping cart program in 6 minutes! ๐
#java #javatutorial #javacourse
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// SHOPPING CART PROGRAM
Scanner scanner = new Scanner(System.in);
String item;
double price;
int quantity;
char currency = $;
double total;
System.out.print(What item would you like to buy?: );
item = scanner.nextLine();
System.out.print(What is the price for each?: );
price = scanner.nextDouble();
System.out.print(How many would you like?: );
quantity = scanner.nextInt();
total = price * quantity;
System.out.println(nYou have bought + quantity + + item +/s);
System.out.println(Your total is + currency + total);
scanner.close();
}
} Code a simple java shopping cart program in 6 minutes! ๐](https://i.ytimg.com/vi/P8CVPIaRmys/mqdefault.jpg)
![Learn Java anonymous classes in 5 minutes! ๐ต๏ธโโ๏ธ
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args) {
// Anonymous class = A class that doesnt have a name. Cannot be reused.
// Add custom behavior without having to create a new class.
// Often used for one time uses (TimerTask, Runnable, callbacks)
Dog dog1 = new Dog();
Dog dog2 = new Dog(){
@Override
void speak(){
System.out.println(Scooby Doo says *Ruh Roh*);
}
};
dog1.speak();
dog2.speak();
}
}
public class Dog {
void speak(){
System.out.println(The dog goes *woof*);
}
} Learn Java anonymous classes in 5 minutes! ๐ต๏ธโโ๏ธ](https://i.ytimg.com/vi/P_iOnmdww8E/mqdefault.jpg)

![How to WRITE FILES with Java in 8 minutes! โ
#java #javatutorial #javacourse
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
// How to write a file using Java (4 popular options)
// FileWriter = Good for small or medium-sized text files
// BufferedWriter = Better performance for large amounts of text
// PrintWriter = Best for structured data, like reports or logs
// FileOutputStream = Best for binary files (e.g., images, audio files)
String filePath = test.txt;
String textContent =
Roses are Red
Violets are Blue
BOOTY BOOTY BOOTY
ROCKIN EVERWHERE!
;
try(FileWriter writer = new FileWriter(filePath)){
writer.write(textContent);
System.out.println(File has been written);
}
catch(FileNotFoundException e){
System.out.println(Could not locate file location);
}
catch(IOException e){
System.out.println(Could not write file);
}
}
} How to WRITE FILES with Java in 8 minutes! โ](https://i.ytimg.com/vi/Pg0aoSbrqOE/mqdefault.jpg)

