No video

Difference between == operator & .equals () method

  Рет қаралды 37,336

Durga Software Solutions

Durga Software Solutions

Күн бұрын

DURGASOFT is INDIA's No.1 Software Training Center offers
online training on various technologies like JAVA, .NET ,
ANDROID,HADOOP,TESTING TOOLS , ADF, INFORMATICA, SAP...
courses from Hyderabad & Bangalore -India with Real Time Experts.
Mail us your requirements to durgasoftonlinetraining@gmail.com
so that our Supporting Team will arrange Demo Sessions.
Ph:Call +91-8885252627,+91-7207212428,+91-7207212427,+91-8096969696.
durgasoft.com
durgasoftonlinetraining.com
/ durgasoftware
durgajobs.com
/ durgajobsinfo.... .

Пікірлер: 13
@-ADeepikaUsike
@-ADeepikaUsike Жыл бұрын
TQ so much sir
@KrishnaDhakate
@KrishnaDhakate 6 жыл бұрын
Whats difference b/w object class "equals()" and "=="?
@rupamshaw
@rupamshaw 8 жыл бұрын
why any of == text in sop doesnt print text it only prints output of boolean class Test{ public static void main(String[] args) { String s4=new String("check"); Thread t=new Thread(); System.out.println(" s4== t "+t==s4); } } output : false but it should print : s4== t false
@rupamshaw
@rupamshaw 8 жыл бұрын
+Rupam Shaw Precedence of operation + is higher than == in java. stackoverflow.com/questions/36528144/any-of-double-equal-text-in-output-doesnt-print-it-only-prints-output-of-bo
@rukeshbabu3131
@rukeshbabu3131 6 жыл бұрын
super sir
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello rukesh, Thanks for your valuable feedback.It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/U1KKyi You an see more Java videos following link: Java tutorial by durga sir goo.gl/XWb4RL Java 9 by durga sir goo.gl/hXGyBW Java 1.8 Version New Features by Durga sir goo.gl/iHXXYU Adv Java JDBC Tutorial by Durga sir goo.gl/8q16Eo OCJA 1.8 Java SE 8 Programmer - I (1Z0 - 808 ) By Durga sir goo.gl/gC6R7f Core Java by NagoorBabu sir goo.gl/s6Nvj1 Advenced Java by Nagoorbabu sir goo.gl/ZZonzJ CoreJava by Ratan goo.gl/3VM19v Advanced Java jdbc by Ratan goo.gl/Rn2UXr Advjava tutorials - JSP by Ratan goo.gl/Z6ytxm Adv java servlets tutorial by ratan goo.gl/zTwi9y Servlet and JSP Tutorial by anji reddy goo.gl/jZMRUv Advanced Java Jdbc by Anjireddy goo.gl/16CGzX Hibernate byAnjireddy goo.gl/qQojvZ Struts by Anjireddy goo.gl/nE1Eof Spring by Mr.AnjiReddy goo.gl/NfN14R ADV JAVA by Naveen goo.gl/bhSsXF Spring by Mr.Naveen goo.gl/huVwFN Hibernate by Mr. Naveen goo.gl/TY3Wpd Struts by Mr.Naveen goo.gl/Vkmiw7
@gajeramilan7194
@gajeramilan7194 9 жыл бұрын
suppose i have String str="youtube"; String str1="youtube"; System.out.println(str==str2);//true String str2=new String("ABC"); String str3=new String("ABC"); System.out.println(str2==str3);//it gives result as false because of str2 and str3 are different object as Above str and str1 it also different object than why it return true?????
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 9 жыл бұрын
Gajera Milan Demo Sessions on youtube, Language Fundamentals(16 Videos)kzfaq.info/get/bejne/m7qIl5tq2Z7Sl30.html, Operators & Assignments(7 Videos)kzfaq.info/get/bejne/Z7B3grOZrt_McYE.html, Flow Control(6 Videos)kzfaq.info/get/bejne/jpyihpynqZ-RoYE.html.
@priyamishra6931
@priyamishra6931 7 жыл бұрын
Gajera Milan
@prajeshpatil8267
@prajeshpatil8267 7 жыл бұрын
"=="operator is used to compare to variable whether to check both the variable are pointing the same object or not.If pointing same Object it returns true else False. In first case without using if we are not using "new" keyword to create string the string object is stored in SCP(String Constant Pool Area). where it checks previous objects with name "youtube"(according to your example")is created or not? for str there is no object with name str so one object is created,while creating next object for str1 it checks previous object and since an object with name "youtube" is availible so reference variable str1 points to the first object without creating new object..hence it returns true. In case 2: The string with "new" keyword stores the string in heap area so for every string a new object is created.So here 2 objects are created with reference variable str2 and str3 respectively containing "youtube" as data in it.As i told "=="is used to compare to variable whether to check both the variable are pointing the same object or not.In this case both str2 and str3 are pointing different objects so it returns false. :)
@richcohen5936
@richcohen5936 6 жыл бұрын
1) String s_1 = "Phil"; String s_2 = "Phil"; System.out.println(s_1.equals(s_2)); // True System.out.println(s_1==s_2); // True 2) String s1 = new String("durga"); String s2 = new String("durga"); System.out.println(s1.equals(s2)); // True System.out.println(s1==s2); // False 3) StringBuffer ss1 = new StringBuffer("john"); StringBuffer ss2 = new StringBuffer("john"); System.out.println(ss1.equals(ss2)); //False System.out.println(ss1==ss2); //False Here in Scenario 1, String direct literals are stored in SCP(String Constant Pool) memory where objects are not deleted until JVM shuts down, meaning objects are not eligible for garbage collection. So, in no. 1 for .equals() method, as it's overridden in String Class of Java it does content comparison unlike .equals() method from Object class. Same content comparison happens for all Wrapper classes and Collection classes as they all override the parent Object class's .equals() method. So, (s_1.equals(s_2)) gives TRUE. Now, == checks reference comparison as it always does. As "Phil" points to the same object in SCP (s_1==s_2) also gives TRUE. Here in Scenario 2, 2 objects are created using new keyword of String type and same String value is stored in both the objects s1 and s2. As .equals() method in String class overrides the parent Object class's .equals() method to do content comparison, (s1.equals(s2)) gives TRUE. Whereas both s1 and s2 are referring to 2 different objects even thought their String value/content is the same, == checks only the address of the object if they're same or not. As they have different address allocated inside memory, (s1==s2) gives FALSE. Here in Scenario 3, StringBuffer Class doesn't override the parent Object class's .equals() method. Hence, it does reference comparison just like it's parent Object class. So, both == and .equals() in scenario 3 does reference comparison. In other words, they both compare the memory address that ss1 and ss2 objects are allocated. If they are same object location then it's True or it's False. As two different objects are created with "new" keyword so they point to two different objects. So, == and .equals() both gives FALSE.
@srikanth29
@srikanth29 6 жыл бұрын
In first case, object is created only for one time in string pool. As the object is same reference is also same. So true. In second case two different objects are created in heap area. So two different references. So false
Difference Between "== Operator" And "equals() Method" In Java (Hindi)
15:02
02. Equals and HashCode Contract & Different Variations
11:19
WebEncyclop Tutorials
Рет қаралды 55 М.
Алексей Щербаков разнес ВДВшников
00:47
My Cheetos🍕PIZZA #cooking #shorts
00:43
BANKII
Рет қаралды 20 МЛН
ТЫ С ДРУГОМ В ДЕТСТВЕ😂#shorts
01:00
BATEK_OFFICIAL
Рет қаралды 10 МЛН
Javaoperators: bitwise operator
19:39
Durga Software Solutions
Рет қаралды 69 М.
JAVA CODING STANDARDS
15:33
Durga Software Solutions
Рет қаралды 114 М.
Differences between String  and StringBuffer
7:57
DURGA EDUCATION
Рет қаралды 543 М.
.equals() vs. == in Java - The Real Difference
8:48
Coding with John
Рет қаралды 184 М.
Difference between Parent p = new Child(); and Child c = new Child();
9:23
Java - Compare the Objects using equals() & hashCode()
16:16
Coding Simplified
Рет қаралды 44 М.
what is the purpose of command line arguments in java
11:31
Durga Software Solutions
Рет қаралды 57 М.
Important Methods of String class: charAt(), concat(), equals(), equalsIgnoreCase()
15:48
Алексей Щербаков разнес ВДВшников
00:47