You should read java Tutorials and Documentation before trying to write your own program code.
Your code is full of syntax errors and logic mistakes.
I don't advice you to begin programming java before understanding core programming concepts:
Declaring variables , if else conditions, loops (while, for)
, reading inputs, printing outputs, logical operators (&& , ||, !)
, arithmetic operators(+, -, *, /, %)
, relational operators(==, !=, >, <)
, operators precedence ....
These concepts are basics in almost every programming language
Programming is a logic thinking not just typing
Check these references to learn java:
In order to get numbers that multiples of 3
in the array list
you can use %
mod operator to check if a number is divisible by 3:
int[] myList = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
for(int i = 0; i < myList.length; i++){
if( myList[i] % 3 == 0){
System.out.println(myList[i]);
}
}
Output:
3
6
9
BUILD SUCCESSFUL (total time: 0 seconds)