Category Archives: Useful Functions

How to find if a number is power 2 ? (Bitwise and Iterative) [Python Script]

As I have promised, I continue answering your questions. One of the readers of myprogrammingblog.com wrote me an email asking How to find if a number is power 2 ? He also asked me to write a bitwise solution as … Continue reading

Posted in open-source, Programming Languages, Python, Useful Functions | Tagged , , , , | 1 Comment

How to check if a number is ODD or Even ? [PHP function]

Hey guys! Long time no seen! Today I had a pleasure of going over myprogrammingblog emails, where many users have asked me to show solutions to different problems. Sorry for not being able to respond earlier, as I had whole … Continue reading

Posted in GitHub, open-source, PHP, Programming Languages, Useful Functions | Tagged , , , , , , , , | 5 Comments

Java – How to format string using SampleDateFormat ?

One of the blog readers asked me this question, how to format string using SampleDateFormat to mm/dd/yyy. Here is a small piece of code, I hope some of you will find it useful. a. Frist – import 2 libraries: b. … Continue reading

Posted in Java, open-source, Useful Functions | Tagged , , , , , , , , , , | 1 Comment

Java: How to split Java String with delimeter comma, space, new line, tab ? [SOLVED]

Sometimes it is very important to split a string on a comma \n \t etc. This piece of code will help you with it. Check out more posts on “Useful Java Functions and Tutorials”

Posted in Java, open-source, Useful Functions | Tagged , , , , , , , , , , , , | 10 Comments

Java: How to find Longest String in ArrayList ? [FUNCTION]

While I was playing with Java code, I have coded a class that has method that finds longest String in the ArrayList. Method is very simple, but I am sure that some of you will find it useful. So here … Continue reading

Posted in Java, open-source, Useful Functions | Tagged , , , , , , , , , , | 3 Comments

Java : How to swap two objects [Problem Solved]

As you might knowJava does not support pointers, thus swapping things around could create problems.  In this post I will show an example of swapping two objects. We have Employee class that holds information about Employees and SwapDemo3 class that … Continue reading

Posted in Java, open-source, Useful Functions | 8 Comments