Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Student Exercise

Small Java programming exercises and tutorials for students.
Deepthi's picture

Java Reverse Array

3.25
Your rating: None Average: 3.3 (4 votes)
Write a Java program to reverse an array without creating another array.
  1. //Java Reverse Array
  2. public class JavaReverseArray {
  3.    
  4.     public static void main(String args[]){
  5.        
  6.         //declare an array
  7.         int[] numbers = {1,2,3,4,5};
  8.        
  9.         System.out.println("Java array before reverse");
  10.         for(int i=0; i < numbers.length ; i++){
  11.          
Ragi Patel's picture

Java ArrayList Average Of All Elements

2.333335
Your rating: None Average: 2.3 (3 votes)
Calculate average of all elements of an ArrayList
  1. //Java ArrayList Average Of All Elements
  2.  
  3. import java.util.ArrayList;
  4.  
  5. public class AverageArrayListElements {
  6.    
  7.     public static void main(String args[]){
  8.        
  9.         //create new ArrayList
  10.         ArrayList<String> aListNumbers = new ArrayList<String>();
  11.         aListNumbers.add("1"
Ragi Patel's picture

Java ArrayList Sum Elements

0
Your rating: None
Calculate sum of all elements of an ArrayList.
  1. import java.util.ArrayList;
  2.  
  3. //Java ArrayList Sum All Elements
  4. public class ArrayListSumElements {
  5.    
  6.     public static void main(String args[]){
  7.        
  8.         //create new ArrayList
  9.         ArrayList<String> aListNumbers = new ArrayList<String>();
  10.         aListNumbers.add("1");
  11.         aLis
zarina's picture

Write a program to generate following pattern using for loop and if statement

5
Your rating: None Average: 5 (2 votes)
  1. /*
  2.     Write a program to generate following pattern using for loop and
  3.     if statement.
  4.    
  5.     1
  6.     22
  7.     333
  8.     4444
  9.     55555
  10.     6666
  11.     777
  12.     88
  13.     9
  14. */
  15. public class iffor{
  16.    
  17.     public static void main(String args[]){
  18.    
  19.         for (int x=1; x<=9; x++){
  20.    
  21.           if(x<=5){
  22.              
  23.               for(int y=1; y<=x; y++){
  24.        
zarina's picture

Java Number Diagonal using For Loop

3
Your rating: None Average: 3 (2 votes)
  1. /*
  2.     Write a program to output the following pattern using for loop.
  3.   1
  4.     2
  5.      3
  6.        4
  7.          5
  8. */
  9.  
  10. public class Diagonal {
  11.  
  12.     public static void main (String[]args) {
  13.  
  14.           for (int x=1; x<=5; x++){
  15.                for (int y=1; y<=x; y++){
  16.                  System.out.print("");
  17.                }
  18.                System.out.println(x);
  19.      
Rahul's picture

Write a program to calculate Cylinder area

5
Your rating: None Average: 5 (2 votes)
  1. /*
  2.  * Write a program to calculate Cylinder area.
Rahul's picture

Write a program to calculate Circle area

1.666665
Your rating: None Average: 1.7 (3 votes)
  1. /*
  2.  * Write a program to calculate Circle area.
Rahul's picture

Write a program to calculate square area

5
Your rating: None Average: 5 (2 votes)
  1. /*
  2.  * Write a program to calculate square area.
Deepali's picture

Write a program to generate following pyramid pattern

2
Your rating: None Average: 2 (1 vote)
  1. /*
  2.    Write a program to generate following pyramid pattern.
Deepali's picture

Write a program to generate following pyramid pattern

5
Your rating: None Average: 5 (2 votes)
  1. /*
  2.    Write a program to generate following pyramid pattern.
Syndicate content