Title | Summary - ssdfsdf |
---|---|
Author | Anonymous User |
Course | Sociology |
Institution | Trường Đại học Ngoại thương |
Pages | 4 |
File Size | 212.1 KB |
File Type | |
Total Downloads | 21 |
Total Views | 138 |
ssdfsdf...
SUMMARY JAVA (OOP)
C
PYTHON (OOP)
JAVASCRIPT
Everything in Java is associated with “Class” and “Object”, along with “attributes” and “methods” Comment Variables
integer
primitive data types
float
character String
// This is a comment line /*This is a comment paragraph*/ byte short int age = 19, weight = 70; long float floatNum = 11.2; double doubleNum = 11.2; char a = ‘T’; String name = “John”; method: length(), toUpperCase(), toLowerCase(), indexOf(), concat(),charAt() int x = 10; String y = “20”; String z = x + y; //1020 a String
// This is a comment line short int long int
var a = 10; let b = 5;
float double long double char a = ‘T’; char name[10] = {“John”};
var a = 1.5;
char str[10]; str = “a string” //This wrong
var a = ‘T’; var a = “A string in JS”;
array
String[] car = {“Volvo”}; int[] myScore = {9,10,10,10,9};
boolean
boolean myBool = true;
Type Casting Other
Input
Output
Print
Operators Condition if…else statement switch…case
x == y; x > y; x short > char > int > long > float > double (int) a; declared a const: final + type of variables ex: final int a = 5; Scanner sc = new Scanner(System.in);
System.out.println(“abc”);
short hand if…else: int result = (a>b) ? 1 : 2; switch (a) { case 0: //Coding here break; case 1:
char arr[] = //This is a string int arr[] = Arrays can only have one type of variable bool a = true; bool a = 1;
(int) a; avoi(string); // string to int avof(string); // string to float declared a const: final + type of variables ex: final int a = 5; scanf(“%d”, &variable);
printf(“abc”);
let arr = [1,2,3,”a”, 4];
const a = 5;
print(“”)
innerHTML()
//Coding here break; default: //Coding here Loop
For
While do…while break; continue; CLASS
Classes
} a loop for a array String[] alphabet ={“a”,”b”,”c”}; for (String i : alphabet) { System.out.println(i); } xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx break to jump out of the loop continue to jump to the next iteration in the loop The name of class have to the same with the name of file. It should start with a Uppercase letter public: need a object to call static: don’t need a object to call public class Main() { }
Objects Attributes Methods
Attributes is variables of class Method is a group of(like Function) Constructors Constructor is a special method
that is used to initialize objects.
Modifiers
public static private
Math
Math.max(12,4); Math.min(12,4); Math.sqrt(); Math.abs(-4.8); Math.random(); //from [0.0 , 1.0)
#include
#include strchr(), strstr(), strtok(), strlen() strcat() – strncat() strcpy() – strncpy() strcmp() – strncmp() Pointers malloc, calloc, realloc...