+ 1
What means ==?
I don't really know what "==" stands for. Can someone help me?
9 odpowiedzi
+ 4
For primitives types, the "==" operator denotes equality. As for objects it denotes whether a certain object points at a certain location within memory.
+ 3
Sure i can.
Using "==" For primitives :
int numOne = 3;
int numTwo = 7;
if(numOne == numTwo){
// they are equal
}else{
// they are NOT equal
}
Using "==" for objects:
Class Tester{
public Tester(){
}
}
Tester t1 = new Tester();
Tester t2 = new Tester();
if(t1 == t2 ){
// they are objects of the same type
}else{
// they are NOT objects of same type
}
To be honest it might also help to read the oracle java tutorials regarding it.
+ 3
EQUALLY OPERATOR:
The equality operator (==) is used to compare two values or expressions. It is used to compare numbers, strings, Boolean values, variables, objects, arrays, or functions. The result is TRUE if the expressions are equal and FALSE otherwise.
ASSIGNMENT OPERATOR:
The assignment operator (=) is used to assign a value to a variable, element of an array, or property of an object ..
+ 1
An = is used to attribute a value to a variable
ex in javascript:
var fName = "Tim";
An == is used in a logical comparison, in an If-statement
ex in javascript
If (fName == 'Tim') {
var result = "Hello I am Tim";
} else {
var result = "Hello I am somebody else";
}
+ 1
I have read it but I didn't understood it. Anyway, thank you @Ousmane!
+ 1
== is logical operator which means equal(=)
inside every loops like if, if else, else if etc logical operators are necessary to execute code. otherwise it will show error message.
other logical operators are:
<= is less than or equal
>= is more than or equal
&& and
|| or
u will learn more about it in upcomming modules.
+ 1
Ok simplest answer here people. == means equal to. Simple
0
@Ousmane Okay, thank you .... Can you give an example?
0
@Caway C, you might want to explore the basics on tutorialspoint and also you must practise it. I find just reading something is ineffective if you dont put it to practise. Good luck anyway!