রবিবার, ১৭ জুলাই, ২০১১
বৃহস্পতিবার, ১৪ জুলাই, ২০১১
About basic Java
What Is Java
Java is a computer programming language created by Sun Microsystems.
The Java programming language is a high-level language that can be characterized by all of the following buzzwords:
|
|
|
|
|
|
|
|
|
|
1. It is free unlike the other rivals.
2. Platform independence (Write Once Run Anywhere).
3. Automatic Garbage collection (Memory management)
Java Object: Object is a real time entity and it has state and behavior.
Java Class: Java class is a blue print of java object.
Abstract class: Abstract classes are super classes which contain abstract methods and are defined such that concrete subclasses are to extend them by implementing the methods.
Concrete class: A concrete class, however, is a class for which entities (instances) may be created. This contrasts with abstract classes which can not be instantiated because it defeats its purpose of being an 'abstract'.
Identifiers:
1. Identifiers must start with a letter, a currency character ($), or a connecting
character such as the underscore ( _ ). Identifiers cannot start with a number!
2. After the first character, identifiers can contain any combination of letters,
currency characters, connecting characters, or numbers.
3. In practice, there is no limit to the number of characters an identifier can
contain.
4. You can't use a Java keyword as an identifier. Table 1-1 lists all of the Java
keywords including one new one for 5.0, enum.
5. Identifiers in Java are case-sensitive; name and NAME are two different identifiers.
JavaBeans: JavaBeans are Java classes that have properties with setter and getter.
JavaBean Property Naming Rules:
1. If the property is not a boolean, the getter method's prefix must be get. getSize()
2. If the property is a boolean, the getter method's prefix is either get or is .getStopped() or isStopped()
3. The setter method's prefix must be set. setSize()
4. Setter method signatures must be marked public, with a void return type
and an argument that represents the property type.
5. Getter method signatures must be marked public, take no arguments, and
have a return type.
Source File Declaration Rules
1. There can be only one public class per source code file.
2. Comments can appear at the beginning or end of any line in the source code
file.
3. If there is a public class in a file, the name of the file must match the name
of the public class. For example, a class declared as public class Dog { }
must be in a source code file named Dog.java.
4. If the class is part of a package, the package statement must be the first line
in the source code file, before any import statements that may be present.
If there are import statements, they must go between the package statement
(if there is one) and the class declaration. If there isn't a package statement,
then the import statement(s) must be the first line(s) in the source code file.
If there are no package or import statements, the class declaration must be
the first line in the source code file.
5. import and package statements apply to all classes within a source code file.
In other words, there's no way to declare multiple classes in a file and have
them in different packages, or use different imports.
6. A file can have more than one nonpublic class.
7. Files with no public classes can have a name that does not match any of the
classes in the file.
Modifiers fall into two categories:
1. Access modifiers: public, protected, private.
2. Non-access modifiers (including strictfp, final, and abstract).
strictfp :
strictfp is a keyword and can be used to modify a class or a method, but never a
variable. Marking a class as strictfp means that any method code in the class will
conform to the IEEE 754 standard rules for floating points. Without that modifier,
floating points used in the methods might behave in a platform-dependent way.
শনিবার, ১৮ জুন, ২০১১
git
To see the list of git commands
git helpTo see help on a git command
git help COMMAND_NAMEConfigure your GIT first time
git config --global user.name "Your Full Name" git config --global user.email "name@therapservices.net"Configure your GIT to get colorize output
git config --global color.status auto git config --global color.diff auto git config --global color.branch autoClone your project
git clone git://masum/therap therap
Clone a bare repository for publishing (for team leads):
git clone --bare git://masum/therap therap
Add release branch
git branch --track release origin/release
Delete branch
git branch -D BRANCH_NAME
Add other’s repo as remote branch
git remote add -t master -t release otherperson git://otherperson/therap
Fetch/merge master from otherperson
git checkout master git fetch git://otherperson master:master git merge otherperson/master
See all the tags (usually used to mark releases)
git tag -l
See list of all commits from a particular release tag to now
git log --no-merges..HEAD git log --no-merges v7.2.4..HEAD
See list of all commits between two release tags
git log --no-merges.. git log --no-merges v7.2.3..v7.2.4
See which files you are changing
git log --stat
See change details too
git log -p --stat
Viewing the changes you have made since last commit
1) git status 2) git diff 3) git diff --cached 4) git diff HEAD
- See status of all files changed or added
- See the changes that you have made but not added, changes in a file after the last git add is also
- See the changes that you have added to commit, changes done in working directory but not added are not shown
- See all changes you have made since last commit (HEAD)
1) git add filePath 2) git add filePattern 3) git add . 4) git add web/WEB-INF/ 5) git add *.java
- Adding a single file
- Adding multiple files
- Adding all files you have changed, give the command from your project root
- Adding all files under web/WEB-INF directory
- Adding all changes to java files
Reset/Undo Changes of a file
git checkout HEAD filepath or git checkout -- filepath
Undo Commit and Keep Changes:
git reset --soft HEAD^
To see who, when added/modified each line of a file
git blame
Make changes in commit message before pulled by anyone else
git commit --amend
More information on git: http://git-scm.com/
Date format match with regular expression
import java.util.regex.Matcher
......
.........
boolean isValidDate(String dates){
//String DATE_PATTERN = "(0?[1-9]|1[012])/(0?[1-9]|[12][0-9]|3[01])/((19|20)\\d\\d)"; // for simple
String DATE_PATTERN = "(((0[13578]|1[02])\\/(0[1-9]|[12]\\d|3[01])\\/((19|[2-9]\\d)\\d{2}))|((0[13456789]|1[012])\\/(0[1-9]|[12]\\d|30)\\/((19|[2-9]\\d)\\d{2}))|(02\\/(0[1-9]|1\\d|2[0-8])\\/((19|[2-9]\\d)\\d{2}))|(02\\/29\\/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))"
// detail solve for 31 problems/ leap year problem
Pattern pattern = Pattern.compile(DATE_PATTERN);
Matcher matcher = pattern.matcher(dates);
if(!matcher.matches()){
return true;
}
else {
return false;
}
}
System.out.println(isValidDate(06/20/2012)); // true
help from .....link
রবিবার, ২৪ এপ্রিল, ২০১১
বৃহস্পতিবার, ২১ এপ্রিল, ২০১১
show hide panel by jquery
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
if($("button").html() == 'show'){
$("button").html("hide");
}
else {
$("button").html("show");
}
$(".panel").slideToggle("slow");
});
});
</script>
<style type="text/css">
div.panel,p.flip
{
margin:0px;
padding:5px;
text-align:center;
background:#e5eecc;
border:solid 1px #c3c3c3;
}
div.panel
{
height:120px;
display:none;
}
</style>
</head>
<body>
<div class="panel">
<p>Because time is valuable, we deliver quick and easy learning.</p>
<p> you can study everything you need to learn, in an accessible and handy format.</p>
</div>
<button>show</button>
</body>
</html>