Monday, February 26, 2018

Using Online javadoc, Java Documentation

Note: Your feedback on how to improve this article is most welcome.

It may not be wise to use old javadoc for example,
http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

Even though this is what our search engine shows first, usually.
However, methods may change from version to version, 
some times they are added,
removed or behavior may change.
Hence always use java doc (documentation) for the latest JDK

How to ensure that google gives result from javadoc for JDK 8?
Here are some interesting ways, just mention java 8 in your search.
Say, we want to search on math class. then write

java 8 math docs
http://www.google.com/search?q=java+8+math+docs

or like,
java 8 api math
http://www.google.com/search?q=java+8+api+math

It does not mean codes vary in different versions of JDK.
Mostly it does not. Codes are usually backward and forward (future) compatible.
However, things do change, slowly. Some of existing code may get
deprecated. There could be changes in behavior.

We should always try to use the latest version because better ways of
doing things may have been introduced and we want our code to keep
working in future JDKs as well.

Recommended Reading:
http://mindprod.com/jgloss/deprecated.html
http://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/deprecation/deprecation.html

Sunday, February 25, 2018

Checking String for Equality

Note: Your feedback on how to improve this post is most welcome.

For comparing String values, ==, !=, >, < are not appropriate. These are better suited to numbers.

For Strings, use something like
Scanner sc = new Scanner(System.in);
System.out.println("Please type + or - or *");
String operator = sc.next();
if (operator.equals ("+"))
{
     System.out.println("you gave a plus sign");
}
else
{
     System.out.println("you gave something else");
}


Recommended reading:

for regular students:
http://alvinalexander.com/java/edu/qanda/pjqa00001.shtml

for advanced learners:
http://docs.oracle.com/javase/tutorial/java/data/comparestrings.html
https://www.javaworld.com/article/2077355/core-java/don-t-be-strung-along.html
https://www.baeldung.com/java-compare-strings


Want to learn more about characters and strings?
https://www.javaworld.com/article/2074031/core-java/jdk-7--java-switching-on-strings-is-here.html
https://www.javaworld.com/article/2074647/core-java/core-java-java-s-character-and-assorted-string-classes-support-text-processing.html

Thursday, February 8, 2018

The Story of a TINY FROG

Also available on many sites including http://slideplayer.com/slide/3166044/

------- Forwarded message ----------
From: Chowdhury Farsad Aurangzeb

TINY FROGS

Once upon a time there was a bunch of tiny frogs.... who arranged a running competition.

The goal was to reach the top of a very high tower.

A big crowd had gathered around the tower to see the race and cheer on the contestants....

The race began....

Honestly:

No one in the crowd really believed that the tiny frogs would reach the top of the tower.

You heard statements such as:

"Oh, WAY too difficult!!"

"They will NEVER make it to the top."

or:

"Not a chance that they will succeed. The tower is too high!"

The tiny frogs began collapsing. One by one....

Except for those, who in a fresh tempo, were climbing higher and higher....

The crowd continued to yell,  "It is too difficult!!! No one will make it!"

More tiny frogs got tired and gave up....

But ONE continued higher and higher and higher....

This one wouldn't give up!

At the end everyone else had given up climbing the tower. Except for the one
tiny frog who, after a big effort, was the only one who reached the top!

THEN all of the other tiny frogs naturally wanted to know how this one frog
managed to do it?

A contestant asked the tiny frog how he had found the strength to succeed
and reach the goal?

It turned out....

That the winner was DEAF!!!!
 
The wisdom of this story is:

Never listen to other people's tendencies to be
 negative or pessimistic....  

because they take your most wonderful dreams
and wishes away from you -- the ones you have in your heart!

Always think of the power words have.

Because everything you hear and read will affect your actions!

Therefore:

ALWAYS be....

POSITIVE!

And above all:

Be DEAF when people tell YOU that you cannot fulfill your dreams!

Always think:

God and I can do this!



---------- Forwarded message ----------
From: Chowdhury Farsad Aurangzeb 
Throughout the semester students get frustrated with studies (like: Programming, maths and etc..). In this situations we have to be the Tiny Frog and inspire ourselves and avoid hearing what people are saying negative about us. If we can't succeed, we have to keep on trying till we can achieve the actual goal. If you fail and keep on trying people might say things that might hold you back and might dis-inspire you  but give damn to those people and keep on trying because the actual LOSER gives up the moment people starts talking negative about them...