General
  • Programming Language
  • Must to have semicollon
  • Typed variable
  • Double quote to assign strings
  • Multiline comments
  • Scripting Language
  • No semicollon
  • Non-typed variable
  • Single or double quote to assign strings
  • Single line comments
Variables
String name = "Sample Name";
NAME="Sample Name"
System.out.print(name);
echo $NAME
String name = "Sampĺe name";

int number = 1;

float count = 1.2f;

String[] names = {"Rafael", "Taís"}

Object[] items = {"A", 1, 2.5}

Map dictionary = new Map<>();
NAME="Sample name"

NUMBER=1

COUNT=1.2

NAMES=(Rafael Tais)

ITEMS=(A 1 2.5)

# No Dictionary
final String name = "Paul";
NAME="Paul"
readonly NAME
static String name = "Paul";
export NAME="Paul"
Arrays
int[] array = {1, 2, 3, 4};
ARRAY=(1 2 3 4)
System.out.println(array[1]); // 2
echo ${ARRAY[1]}; # 2
array[1] = 20;
ARRAY[1] = 20;
ArrayUtils.add(array, 5);
ARRAY+=(5)
ArrayUtils.remove(array, 1);
unset ARRAY[1]
Conditions
if(i > 10) {
  System.out.println("Hi");
}else if(i < 2) {
  System.out.println("Hello");
}else {
  System.out.println("Bye");
}
if [ $i -gt 10 ] 
then
  echo "Hi"
elif [ $ -lt 2 ]
then
  echo "Hello"
else
  echo "Bye"
fi
Loops
for (int i: array) {
  System.out.print(i);
}
for i in ${ARRAY[*]}
do
  echo $i
done
while(i < 10){
  System.out.println(i);
  i--;
}
while [ $i -lt 10 ]
do
  echo $i
  i=$((i-1))
done
Functions
void calc (int y, int x) {
  int r = x * y;
}
calc (){
  x=$1
  y=$2
  r = (x * y)
}
int calc (int y, int x) {
  return x * y;
}
calc (){
  x=$1
  y=$2
  echo (x * y)
}
  
calc (10, 20);
calc 10 20
Misc
// comment
# comment
Sytem.out.print("printable");
echo "printable"