Jump to content

Recommended Posts

Posted

evaraina hashcode and equals gurunchi cheputara.inka what is meant by synchronization.

And also difference between throw and throws?

Posted

throws is used when we want to catch ask exception at class level instead of having multiple try- catch blocks

Posted

throw is used for the capability to be able to throw custom exceptions in our code 

Posted

1. hashcode n equals

 

Assume you have some buckets and each bucket contains a list of names

 

if someone asks you to find a bucket which contains a name some "xyz"

 

for this we need to do 2 things

 

1. first we need to find the right bucket

2, compare the name "xyz" with others

 

So hashcode will help you to find the right bucket. and equals method used to compare "xyz" with the names in the bucket and returns true if it equals

Posted

Bhaiyya got ur bucket theme can you explain now in java

Posted

1. hashcode n equals

 

Assume you have some buckets and each bucket contains a list of names

 

if someone asks you to find a bucket which contains a name some "xyz"

 

for this we need to do 2 things

 

1. first we need to find the right bucket

2, compare the name "xyz" with others

 

So hashcode will help you to find the right bucket. and equals method used to compare "xyz" with the names in the bucket and returns true if it equals

()>>  ()>>  ()>>  ()>>

Posted

we have got a scenario like

 

deposit, check balance, withdrawal

 

assume the account is mutual(used by multiple users A, B)

 

Assume the current amount is 100$

 

A deposits money - 100$

B withdraws money- 100$

A checks balance - 100$ will be shown in the statement

 

assume if all the operations are done at a time, it will be a collapse user 'A' will be shocked, because these operations can be done parallelly

 

But if you synchronize the deposit(), withdraw(), checkbalance() only one user can be accessed at a time

Once A finishes his job, B will b allowed to withdraw

 

 

 

 

×
×
  • Create New...