Online tools
Web school
在线工具
基础教程
菜鸟教程
编程学习
Web 学校
❮
❯
HTML
CSS
JAVASCRIPT
SQL
PYTHON
JAVA
PHP
HOW TO
W3.CSS
C
C++
C#
BOOTSTRAP
REACT
MYSQL
JQUERY
EXCEL
XML
DJANGO
NUMPY
PANDAS
NODEJS
DSA
TYPESCRIPT
ANGULAR
ANGULARJS
GIT
POSTGRESQL
MONGODB
ASP
AI
R
GO
KOTLIN
SWIFT
SASS
VUE
GEN AI
SCIPY
AWS
CYBERSECURITY
DATA SCIENCE
INTRO TO PROGRAMMING
INTRO TO HTML & CSS
BASH
RUST
TOOLS
Java Tutorial
Java HOME
Java Intro
Java Get Started
Java Syntax
Syntax
Statements
Code Challenge
Java Output
Print Text
Print Numbers
Code Challenge
Java Comments
Java Variables
Variables
Print Variables
Multiple Variables
Identifiers
Constants (Final)
Real-Life Examples
Code Challenge
Java Data Types
Data Types
Numbers
Booleans
Characters
Real-Life Example
Non-primitive Types
The var Keyword
Code Challenge
Java Type Casting
Java Operators
Operators
Arithmetic
Assignment
Comparison
Logical
Precedence
Code Challenge
Java Strings
Strings
Concatenation
Numbers and Strings
Special Characters
Code Challenge
Java Math
Java Booleans
Booleans
Real-Life Example
Code Challenge
Java If...Else
if
else
else if
Short Hand If...Else
Nested If
Logical Operators
Real-Life Examples
Code Challenge
Java Switch
Switch
Code Challenge
Java While Loop
While Loop
Do/While Loop
Real-Life Examples
Code Challenge
Java For Loop
For Loop
Nested Loops
For-Each Loop
Real-Life Examples
Code Challenge
Java Break/Continue
Java Arrays
Arrays
Loop Through an Array
Real-Life Examples
Multidimensional Arrays
Code Challenge
Java Methods
Java Methods
Java Method Challenge
Java Method Parameters
Parameters
Return Values
Code Challenge
Java Method Overloading
Java Scope
Java Recursion
Java Classes
Java OOP
Java Classes/Objects
Java Class Attributes
Java Class Methods
Java Class Challenge
Java Constructors
Java this Keyword
Java Modifiers
Access Modifiers
Non-Access Modifiers
Java Encapsulation
Java Packages / API
Java Inheritance
Java Polymorphism
Java super Keyword
Java Inner Classes
Java Abstraction
Java Interface
Java Anonymous
Java Enum
Enums
Enum Constructor
Java User Input
Java Date
Java Errors
Java Errors
Java Debugging
Java Exceptions
Java Multiple Exceptions
Java try-with-resources
Java File Handling
Java Files
Java Create Files
Java Write Files
Java Read Files
Java Delete Files
Java I/O Streams
Java I/O Streams
Java FileInputStream
Java FileOutputStream
Java BufferedReader
Java BufferedWriter
Java Data Structures
Java Data Structures
Java Collections
Java List
Java ArrayList
Java LinkedList
Java List Sorting
Java Set
Java HashSet
Java TreeSet
Java LinkedHashSet
Java Map
Java HashMap
Java TreeMap
Java LinkedHashMap
Java Iterator
Java Algorithms
Java Advanced
Java Wrapper Classes
Java Generics
Java Annotations
Java RegEx
Java Threads
Java Lambda
Java Advanced Sorting
Java Projects
Java Projects
Java Cert
Java Certificate
Java How To's
Java How Tos
How Tos
Add Two Numbers
Swap Two Variables
Even or Odd Number
Reverse a Number
Positive or Negative
Square Root
Area of Rectangle
Celsius to Fahrenheit
Sum of Digits
Check Armstrong Num
Random Number
Count Words
Count Vowels in a String
Remove Vowels
Count Digits in a String
Reverse a String
Palindrome Check
Check Anagram
Convert String to Array
Remove Whitespace
Count Character Frequency
Sum of Array Elements
Find Array Average
Sort an Array
Find Smallest Element
Find Largest Element
Second Largest Array
Min and Max Array
Merge Two Arrays
Remove Duplicates
Find Duplicates
Shuffle an Array
Factorial of a Number
Fibonacci Sequence
Find GCD
Check Prime Number
ArrayList Loop
HashMap Loop
Loop Through an Enum
Java Reference
Java Reference
Java Keywords
assert
abstract
boolean
break
byte
case
catch
char
class
continue
default
do
double
else
enum
exports
extends
final
finally
float
for
if
implements
import
instanceof
int
interface
long
module
native
new
package
private
protected
public
return
requires
short
static
super
switch
synchronized
this
throw
throws
transient
try
var
void
volatile
while
Java String Methods
charAt()
codePointAt()
codePointBefore()
codePointCount()
compareTo()
compareToIgnoreCase()
concat()
contains()
contentEquals()
copyValueOf()
endsWith()
equals()
equalsIgnoreCase()
format()
getBytes()
getChars()
hashCode()
indexOf()
isEmpty()
join()
lastIndexOf()
length()
matches()
offsetByCodePoints()
regionMatches()
replace()
replaceAll()
replaceFirst()
split()
startsWith()
subSequence()
substring()
toCharArray()
toLowerCase()
toString()
toUpperCase()
trim()
valueOf()
Java Math Methods
abs()
acos()
addExact()
asin()
atan()
atan2()
cbrt()
ceil()
copySign()
cos()
cosh()
decrementExact()
exp()
expm1()
floor()
floorDiv()
floorMod()
getExponent()
hypot()
IEEEremainder()
incrementExact()
log()
log10()
log1p()
max()
min()
multiplyExact()
negateExact()
nextAfter()
nextDown()
nextUp()
pow()
random()
rint()
round()
scalb()
signum()
sin()
sinh()
sqrt()
subtractExact()
tan()
tanh()
toDegrees()
toIntExact()
toRadians()
ulp()
Java Output Methods
print()
printf()
println()
Java Arrays Methods
compare()
equals()
sort()
fill()
length
Java ArrayList Methods
add()
addAll()
clear()
clone()
contains
ensureCapacity()
forEach()
get()
indexOf()
isEmpty()
iterator()
lastIndexOf()
listIterator()
remove()
removeAll()
removeIf()
replaceAll()
retainAll()
set()
size()
sort()
spliterator()
subList()
toArray()
trimToSize()
Java LinkedList Methods
add()
addAll()
clear()
clone()
contains
forEach()
get()
getFirst()
getLast()
indexOf()
isEmpty()
iterator()
lastIndexOf()
listIterator()
remove()
removeAll()
removeFirst()
removeIf()
removeLast()
replaceAll()
retainAll()
set()
size()
sort()
spliterator()
subList()
toArray()
Java HashMap Methods
clear()
clone()
compute()
computeIfAbsent()
computeIfPresent()
containsKey()
containsValue()
entrySet()
forEach()
get()
getOrDefault()
isEmpty()
keySet()
merge()
put()
putAll()
putIfAbsent()
remove()
replace()
replaceAll()
size()
values()
Java Scanner Methods
close()
delimiter()
findInLine()
findWithinHorizon()
hasNext()
hasNextBoolean()
hasNextByte()
hasNextDouble()
hasNextFloat()
hasNextInt()
hasNextLine()
hasNextLong()
hasNextShort()
locale()
next()
nextBoolean()
nextByte()
nextDouble()
nextFloat()
nextInt()
nextLine()
nextLong()
nextShort()
radix()
reset()
useDelimiter()
useLocale()
useRadix()
Java File Methods
Java FileInputStream
Java FileOutputStream
Java BufferedReader
Java BufferedWriter
Java Iterator Methods
Java Collections Methods
Java System Methods
Java Errors & Exceptions
Java Examples
Java Examples
Java Videos
Java Compiler
Java Exercises
Java Quiz
Java Code Challenges
Java Practice Problems
Java Server
Java Syllabus
Java Study Plan
Java Interview Q&A
Java Examples
❮ Previous
Next ❯
Java Syntax
Create a simple "Hello World" program
Syntax Explained
Java Comments
Single-line comment before a line of code
Single-line comment at the end of a line of code
Multi-line comment
Comments Explained
Java Variables
Create a string variable
Create an integer variable
Create a variable without assigning the value, and assign the value later
Overwrite an existing variable value
Create a final variable (unchangeable and read-only)
Combine text and a variable on display
Add a variable to another variable
Declare many variables of the same type with a comma-separated list
Variables Explained
Java Data Types
A demonstration of different data types in Java
Create a byte type
Create a short type
Create an int type
Create a long type
Create a float type
Create a double type
Create a boolean type
Create a char type
Create a String type
Data Types Explained
Java Type Casting
Widening Casting
Narrowing Casting
Type Casting Explained
Java Operators
Addition operator
Subtraction operator
Multiplication operator
Division operator
Modulus operator
Increment operator
Decrement operator
Assignment operator
Comparison operator
Logical operator
Operators Explained
Java Strings
Create a string
Quotes inside a string
Find the length of a string
Using methods to convert strings to uppercase and lowercase
Finding a string in a string
String concatenation
If you add a number and a string, the result will be a string concatenation
Strings Explained
Java Math
Math.max(x,y) - return the highest value of x and y
Math.min(x,y) - return the lowest value of x and y
Math.sqrt(x) - return the square root of x
Math.abs(x) - return the absolute (positive) value of x
Math.random() - return a random number between 0 and 1
Math Explained
Java Booleans
Create a boolean type
Find out if an expression is true or false
Use the "equal to" operator to evaluate a boolean expression
Booleans Explained
Java If...Else (Conditions)
The if statement
The else statement
The else if statement
If...Else Explained
Java Switch
The switch statement
The switch statement with a default keyword
Switch Explained
Java Loops
While loop
Do while loop
For loop
For-each loop
Break a loop
Continue a loop
Loops Explained
Java Arrays
Create and access an array
Change an array element
Find the length of an array
Access an array
Loop through an array
Loop through an array with for-each
Multidimensional array
Loop through a multidimensional array
Arrays Explained
Java Methods
Create and call a method
Call a method multiple times
Method with parameters
Method with multiple parameters
Return value
A method with if...else
Method overloading
Recursion
Recursive function with a halting condition
Methods Explained
Java Classes and Objects
Create a class and an object of a class
Create multiple objects of a class
Accessing class attributes (variables)
Modify attributes
Override existing attribute values
Multiple attributes
Create a class method
Method with parameters
Access class methods with an object
Create a class constructor
Constructor with parameters
Classes and Objects Explained
Java Modifiers
Public class
Default class
Public attributes
Private attributes
Default attributes
Protected attributes
Final class
Abstract class with abstract methods
Modifiers Explained
Java Encapsulation
Java encapsulation (getters and setters)
Encapsulation Explained
Java Packages
Import a class from the Java API
Import a package from the Java API
Create a package
Packages Explained
Java Inheritance
Java inheritance (extends)
Java polymorphism
Inheritance Explained
Java Inner Classes
Inner class
Private inner class (error when trying to access it from an outside class)
Static inner class
Access outer class from inner class
Inner Classes Explained
Java Abstraction & Interfaces
Java abstract classes and methods
Java interface (implements)
Multiple interfaces
Interfaces Explained
Java Enums
Create an enum with a group of constants
An enum inside a class
An enum in a switch statement
Loop through an enum
Enums Explained
Java User Input
Read user input
Read user input of various types
User Input Explained
Java Dates
Display current date
Display current time
Display current date and time
Formatting date and time
Dates Explained
Java ArrayList
Create an ArrayList
Access an item in an ArrayList
Remove an item from an ArrayList
Remove all items from an ArrayList
Get the size of an ArrayList
Loop through an ArrayList
Loop through an ArrayList with for-each
Create an ArrayList that should store numbers (integers)
ArrayList Explained
Java HashMap
Create a HashMap
Access an item in a HashMap
Remove an item from a HashMap
Remove all items from a HashMap
Get the size of a HashMap
Loop through a HashMap
Create a HashMap that should store String keys and Integer values
HashMap Explained
Java HashSet
Create a HashSet and add items to it
Check if an item exists in a HashSet
Remove an item from a HashSet
Remove all items from a HashSet
Get the size of a HashSet
Loop through a HashSet
Create a HashSet that should store Integer values
HashSet Explained
Java Iterator
Getting an iterator
Looping throug a collection
Removing items from a collection
Iterator Explained
Java Wrapper Classes
Create an ArrayList that should store numbers (integers)
Create wrapper objects
Using wrapper methods
Convert wrapper objects to strings
Wrapper Classes Explained
Java Exceptions (Try...Catch)
The try...catch statement
The finally statement
The throw statement
Exceptions Explained
Java Regular Expressions
Search for the word "w3schools" in a sentence
Regular Expressions Explained
Java Threads
Running a thread by extending the thread class
Running a thread by implementing the Runnable interface
Concurrency problems
Avoid concurrency problems
Threads Explained
Java Files
Create a file
Write to a file
Read a file
Get file information
Delete a file
Files Explained
❮ Previous
Next ❯
★ +1
Sign in to track progress
COLOR PICKER
REMOVE ADS
-->