Java program to find greatest number in array:
package arraydemo;
public class ArrayDemo {
public static void main(String[] args) {
int numbers[] = new int[]{11,12,13,44,55,66,77,88,99,23};
int small = numbers[0];
int large = numbers[0];
for(int i=1; i< numbers.length; i++)
{
if(numbers[i] > large)
large = numbers[i];
else if (numbers[i] < small)
small = numbers[i];
}
System.out.println("Largest Number is : " + large);
System.out.println("Smallest Number is : " + small);
}
}
OUTPUT:
Largest Number is : 99
Smallest Number is : 11
Related Posts:
Fibonacci Using Recusion method
Fibonacci Using Recusion method:
package diamond;
import static diamond.Fibonacci.fibonacciRecusion;
public class FibonacciDemo {
pu… Read More
Character Extraction
Character Extraction:
2)getChars()
If you want to extract more than one character at a time,you can use the getChars() method.
It has general form… Read More
Java program to show number pyramid
Number Pyramid:
package diamond;
public class PyramidDemo {
public static void main(String[] args) {
for… Read More
replace() method
Modifying a String:
replace();
The replace method is used to replace the one character of string.It has the general form:
&nbs… Read More
Character Extraction
Character Extraction:
1) charAt()
charAt() method is used to extract single character from String.Here is a small program to demonstrate chatAt() … Read More
0 comments:
Post a Comment