# Find a pair with the Given Sum in an Array in Java2 min read

In this tutorial, we will write a java program to find the sum pair in an array. Before that, you may go through the following topics in java.

The program takes a user input for a number of elements in an array and then the value of elements. After that, the program asks for the number to be checked for the sum and the calculation is done.

## Find a Pair with the Given Sum in an Array in Java

Output 1:

`How many elements5Enter the elements:12345Enter the value to be checked:80Pair not found!`

Output 2:

`How many elements5Enter the elements:12345Enter the value to be checked:7Pair:(2, 5)Pair:(3, 4)`

### The time complexity for the worst case.

Big O: O(n2)

All the single line statement states represent with -> 1
And loop are represented with the number of times it loops and each of the program loops for “n” number of times, hence each loop represents n complexity.

Now the last for loop has one more for loop nested inside and since for leep here represents n complexity, therefore the last nested loop gices “n2” (n to the power 2) complexity.
And highest being the “n2”, therefor big O is n2.

### String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …

### Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …

### Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …

### Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …

### Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …

### Inverted Half Pyramid Pattern of Alphabets in C

In this tutorial, we will write a C program to print half Pyramid using alphabets/characters. Before that, you may go through the following topic in …