SlideShare a Scribd company logo
Java small tests
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1==s3 -> " + (s1==s3));
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1==s3 -> " + (s1==s3));
s1==s3 -> false
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1.equals(s3) -> " +
s1.equals(s3));
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1.equals(s3) -> " +
s1.equals(s3));
s1.equals(s3) -> true
String s1 = "Hello";
String s2 = "Hello";
System.out.println("s1==s2 -> " + (s1==s2));
String s1 = "Hello";
String s2 = "Hello";
System.out.println("s1==s2 -> " + (s1==s2));
s1==s2 -> true
class Test
{
protected void finalize()
{
System.out.println("finalize!!!");
}
}
void test_finalize()
{
for(int i=0;i<5;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
class Test
{
protected void finalize()
{
System.out.println("finalize!!!");
}
}
void test_finalize()
{
for(int i=0;i<5;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
i = 0
i = 1
i = 2
i = 3
i = 4
finalize!!!
finalize!!!
finalize!!!
finalize!!!
finalize!!!
class Test
{
protected void finalize()
{
System.out.println("Exit");
System.exit(0);
}
}
void test_finalize()
{
for(int i=0;i<500000;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
class Test
{
protected void finalize()
{
System.out.println("Exit");
System.exit(0);
}
}
void test_finalize()
{
for(int i=0;i<500000;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
…
i = 63624
i = 63625
i = 63626
i = 63627
i = 63628
i = 63629
Exit
i = 63630
i = 63631
i = 63632
i = 63633
i = 63634
i = 63635
i = 63636
i = 63637
i = 63638

More Related Content

Similar to Java Small Tests (12)

PPT
Strings and Characters
Andy Juan Sarango Veliz
 
PDF
Learn Java Part 6
Gurpreet singh
 
PDF
C Strings oops with c++ ppt or pdf can be done.pdf
kings30112004
 
PPTX
Java String Handling
Infoviaan Technologies
 
PPT
Training Java - Lesson3
mittoq
 
PDF
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
shettysachin2005
 
DOCX
QA Auotmation Java programs,theory
archana singh
 
PPTX
Strings CPU GTU
Maharshi Dave
 
PPTX
07. Java Array, Set and Maps
Intro C# Book
 
PPTX
Scala == Effective Java
Scalac
 
PPTX
String.pptxihugyftgrfxdf bnjklihugyfthfgxvhbjihugyfthcgxcgvjhbkipoihougyfctgf...
minifriendofyou
 
PDF
JavaScript - Chapter 10 - Strings and Arrays
WebStackAcademy
 
Strings and Characters
Andy Juan Sarango Veliz
 
Learn Java Part 6
Gurpreet singh
 
C Strings oops with c++ ppt or pdf can be done.pdf
kings30112004
 
Java String Handling
Infoviaan Technologies
 
Training Java - Lesson3
mittoq
 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
shettysachin2005
 
QA Auotmation Java programs,theory
archana singh
 
Strings CPU GTU
Maharshi Dave
 
07. Java Array, Set and Maps
Intro C# Book
 
Scala == Effective Java
Scalac
 
String.pptxihugyftgrfxdf bnjklihugyfthfgxvhbjihugyfthcgxcgvjhbkipoihougyfctgf...
minifriendofyou
 
JavaScript - Chapter 10 - Strings and Arrays
WebStackAcademy
 

More from Maksym Davydov (20)

PDF
Firebase overview
Maksym Davydov
 
PDF
Microsoft mobile services
Maksym Davydov
 
PDF
Design of mobile apps
Maksym Davydov
 
PDF
Mobile app design feature development
Maksym Davydov
 
PDF
Android mix Java and C++
Maksym Davydov
 
PDF
Android animations
Maksym Davydov
 
PDF
Handler declaration in layout
Maksym Davydov
 
PDF
Android Networking
Maksym Davydov
 
PDF
Android Storage
Maksym Davydov
 
PDF
Interface Programming Android
Maksym Davydov
 
PDF
Android Programming Intro
Maksym Davydov
 
PDF
Lecture 02 Mobile hardware
Maksym Davydov
 
PDF
Lecture 01 Mobile operating systems
Maksym Davydov
 
PDF
Lecture 13 Local Optimization on Mobile Devices
Maksym Davydov
 
PDF
Lecture 12. iOS and Android Animations
Maksym Davydov
 
PDF
Lecture 11. Microsoft mobile services
Maksym Davydov
 
PDF
Lecture 11 Firebase overview
Maksym Davydov
 
PDF
Lecture 10 Networking on Mobile Devices
Maksym Davydov
 
PDF
Lecture 09 Android Storage
Maksym Davydov
 
PDF
Lecture 08 Xamarin
Maksym Davydov
 
Firebase overview
Maksym Davydov
 
Microsoft mobile services
Maksym Davydov
 
Design of mobile apps
Maksym Davydov
 
Mobile app design feature development
Maksym Davydov
 
Android mix Java and C++
Maksym Davydov
 
Android animations
Maksym Davydov
 
Handler declaration in layout
Maksym Davydov
 
Android Networking
Maksym Davydov
 
Android Storage
Maksym Davydov
 
Interface Programming Android
Maksym Davydov
 
Android Programming Intro
Maksym Davydov
 
Lecture 02 Mobile hardware
Maksym Davydov
 
Lecture 01 Mobile operating systems
Maksym Davydov
 
Lecture 13 Local Optimization on Mobile Devices
Maksym Davydov
 
Lecture 12. iOS and Android Animations
Maksym Davydov
 
Lecture 11. Microsoft mobile services
Maksym Davydov
 
Lecture 11 Firebase overview
Maksym Davydov
 
Lecture 10 Networking on Mobile Devices
Maksym Davydov
 
Lecture 09 Android Storage
Maksym Davydov
 
Lecture 08 Xamarin
Maksym Davydov
 
Ad

Recently uploaded (20)

PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Ad

Java Small Tests

  • 2. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1==s3 -> " + (s1==s3));
  • 3. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1==s3 -> " + (s1==s3)); s1==s3 -> false
  • 4. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1.equals(s3) -> " + s1.equals(s3));
  • 5. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1.equals(s3) -> " + s1.equals(s3)); s1.equals(s3) -> true
  • 6. String s1 = "Hello"; String s2 = "Hello"; System.out.println("s1==s2 -> " + (s1==s2));
  • 7. String s1 = "Hello"; String s2 = "Hello"; System.out.println("s1==s2 -> " + (s1==s2)); s1==s2 -> true
  • 8. class Test { protected void finalize() { System.out.println("finalize!!!"); } } void test_finalize() { for(int i=0;i<5;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); }
  • 9. class Test { protected void finalize() { System.out.println("finalize!!!"); } } void test_finalize() { for(int i=0;i<5;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); } i = 0 i = 1 i = 2 i = 3 i = 4 finalize!!! finalize!!! finalize!!! finalize!!! finalize!!!
  • 10. class Test { protected void finalize() { System.out.println("Exit"); System.exit(0); } } void test_finalize() { for(int i=0;i<500000;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); }
  • 11. class Test { protected void finalize() { System.out.println("Exit"); System.exit(0); } } void test_finalize() { for(int i=0;i<500000;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); } … i = 63624 i = 63625 i = 63626 i = 63627 i = 63628 i = 63629 Exit i = 63630 i = 63631 i = 63632 i = 63633 i = 63634 i = 63635 i = 63636 i = 63637 i = 63638