Java Program to Find Missing Number in Array

Write a java program to find missing number in array. Given an array of n-1 integers and these integers are in the range of 1 to n. One of the integer is missing from an array. We have to write an efficient java code to find missing number from an array. An array does not contains any duplicates.

PHP Composer : Manage Package Dependency in PHP

What’s a PHP composer? How to use PHP composer in your PHP Application? What are the benefits of using composer in your application?

PHP Composer is a dependency manager. It manages the dependency of PHP packages in your application. Using composer you can pull the required library and dependencies and manage them in one place. The concept of a composer is similar to npm in node.js and gem in Ruby.

Let’s first understand what is a dependency.

Magic Methods in PHP

What are PHP Magic Methods?

PHP Magic methods are a specialized method that is executed in response to a specific event. Each magic methods start with two underscores(__) and it is called automatically when a certain condition is met. It triggers custom behaviors defined by a programmer inside the class. Some of the magic methods are __construct(), __destruct(),  __toString(),  __get(),  __set(), __call() etc.

In this tutorial, we are going to explore these magic methods.

PHP Magic Methods

PHP Magic Methods

Find GCD of Two Numbers using Recursion – Java Code

Write a Java program to find GCD of two numbers using Recursion. Given two input integers, we have to write a code to find GCD of two numbers using recursion. For this program, I assume you are familiar with the concept of recursion. If you don’t know about recursion then check my previous post on recursion vs iteration.

Using Interface in PHP

What is an interface in PHP? An interface is an important concept in an object oriented programming.

In this tutorial, we’ll discuss following points.

1. What is an interface?

2. How to create an interface in PHP.

3. What’s the importance of using an interface in our PHP application?

Interface in PHP

Interface in PHP

What is an Interface in PHP?

An Interface defines a contract for what a class can do, without saying anything about how the class can do it. Through interfaces, we define what a class can do, the classes that implement interface define how it can do it.

To understand the concept of an interface let’s take an example of a caching system. There are different types of caching available such as File system, Memcache, Redis etc. First, we need to define what a cache can do (I mean different operations), how we do it? we can do it through an interface. A class (Such as Memcache, Redis etc) which implements cache interface will define how they will do it.

NOTE – An interface will not add any additional functionality in your code but it outlines a standard format to which your classes need to use.

Java Program to Find the First Non-repeated Character in a String

Write a java program to find the first non-repeated character in a string.Given an input string, we have to write a java code to find the first non-repeated character in a string.

For example –

i) Input string – java
Output – j (j is the first non-repeating character in a string)

ii) Input string – web rewrite
Output – b (b is the first non-repeating character in a string)