Tuesday, August 31, 2010
Monday, August 30, 2010
Access Modifier
private
public
protected
package
static
final
abstract
public
protected
package
static
final
abstract
Hashcode Method
The hashCode() method of java.lang.Object
Anytime you override equals() you should also override hashCode(). The hashCode() method should ideally return the same int for any two objects that compare equal and a different int for any two objects that don't compare equal, where equality is defined by the equals() method. This is used as an index by the java.util.Hashtable class.
In the Car example equality is determined exclusively by comparing license plates; therefore only the licensePlate field is used to determine the hash code. Since licensePlate is a String, and since the String class has its own hashCode() method, we can sponge off of that.
public int hashCode() {
return this.licensePlate.hashCode();
}
Other times you may need to use the bitwise operators to merge hash codes for multiple fields. There are also a variety of useful methods in the type wrapper classes (java.lang.Double, java.lang.Float, etc.) that convert primitive data types to integers that share the same bit string. These can be used to hash primitive data types.
Anytime you override equals() you should also override hashCode(). The hashCode() method should ideally return the same int for any two objects that compare equal and a different int for any two objects that don't compare equal, where equality is defined by the equals() method. This is used as an index by the java.util.Hashtable class.
In the Car example equality is determined exclusively by comparing license plates; therefore only the licensePlate field is used to determine the hash code. Since licensePlate is a String, and since the String class has its own hashCode() method, we can sponge off of that.
public int hashCode() {
return this.licensePlate.hashCode();
}
Other times you may need to use the bitwise operators to merge hash codes for multiple fields. There are also a variety of useful methods in the type wrapper classes (java.lang.Double, java.lang.Float, etc.) that convert primitive data types to integers that share the same bit string. These can be used to hash primitive data types.
Saturday, August 28, 2010
Operator Precedence
1) . [] ()
2) ++ -- ! ~ instanceof
3) new(type)expression
4) * / %
5) + -
6) << >> >>>
7) < > <= >=
8) == !=
9) &
10) ^
11) |
12) &&
13) ||
2) ++ -- ! ~ instanceof
3) new(type)expression
4) * / %
5) + -
6) << >> >>>
7) < > <= >=
8) == !=
9) &
10) ^
11) |
12) &&
13) ||
Friday, August 27, 2010
How to run Package Program
I am taking same example as in ur book i.e.
Created Cards Folder and then domains folder and file in it i.e. Suit.java,Playingcard.java
Created tests folder inside Cards folder and file TestPlayingCard.java
_________________________
Know How to Compile that
_________________________
In command Prompt be in Cards folder then write following command :-
___________________________
To Run
___________________________
In cards folder in command prompt
java cards.tests.TestPlayingCart
Created Cards Folder and then domains folder and file in it i.e. Suit.java,Playingcard.java
Created tests folder inside Cards folder and file TestPlayingCard.java
_________________________
Know How to Compile that
_________________________
In command Prompt be in Cards folder then write following command :-
- javac -d . domain\Suit.java
- javac -d . domain\PlayingCard.java
- javac -d . tests\TestPlayingCard.java
___________________________
To Run
___________________________
In cards folder in command prompt
java cards.tests.TestPlayingCart
Thursday, August 26, 2010
MR Excercis is added
MR excercise is added in Program->Program->Java Mr Program -> today date
Thursday, August 19, 2010
Fwd: [java] New comment on Problem.
I had uploaed more program and setup is updated
---------- Forwarded message ----------
From: Anonymous <noreply-comment@blogger.com>
Date: Thu, Aug 19, 2010 at 10:49 PM
Subject: [java] New comment on Problem.
To: vivlinux@gmail.com
Anonymous has left a new comment on your post "Problem":
hello sir,
its very difficult to cope up with the theory without the practicle knowledge.
so pls add the remaining portion of the setup as soon as you can..
Akshay Arora
Posted by Anonymous to java at August 19, 2010 10:19 AM
From: Anonymous <noreply-comment@blogger.com>
Date: Thu, Aug 19, 2010 at 10:49 PM
Subject: [java] New comment on Problem.
To: vivlinux@gmail.com
Anonymous has left a new comment on your post "Problem":
hello sir,
its very difficult to cope up with the theory without the practicle knowledge.
so pls add the remaining portion of the setup as soon as you can..
Akshay Arora
Posted by Anonymous to java at August 19, 2010 10:19 AM
Thursday, August 12, 2010
jdk setup
__________________________________
_______________________________
______________________________
download this two and extract and install
Subscribe to:
Posts (Atom)