Write a program of Fibonacci series using Recursion in Java

Code:
 import java.util.Scanner;  
 public class FibonacciRecursion {  
      public static void main(String args[]) {  
           Scanner scanner = new Scanner(System.in);  
           System.out.println("Enter the number for Fibonacci series:");  
           int num = scanner.nextInt();  
           System.out.println("Fibonacci Series:");  
           for (int i=0;i<num;i++) {  
           System.out.print(fibonacci(i) + ",");  
           }  
           scanner.close();  
      }  
      public static int fibonacci(int num) {  
           if (num == 0) {  
                return 0;  
           } else if (num == 1) {  
                return 1;  
           } else {  
                return fibonacci(num-2) + fibonacci(num-1);  
           }  
      }  
 }  
Output :
Enter the number for Fibonacci series:
8
Fibonacci series:
0,1,1,2,3,5,8,13,

JSP declaration tag

A JSP declaration is used to declare variables and methods in a page’s scripting language.

The syntax for a declaration is as follows:
<%! scripting-language-declaration %>

Example for declaring Variable:
index.jsp
 <html>   
 <body>   
 <%! int a=5; %>   
 <%= "Value of Integer a is "+ (++a) %>   
 </body>   
 </html>   

Example for declaring method : 
index.jsp
 <HTML>  
 <BODY>  
 <%!  
   void getName()  
   {  
     System.out.println( "LoveJavaBytes" );  
   }  
 %>  
 Name is : <%= getName() %>  
 </BODY>  
 </HTML>  

JSP expression tag

A JSP expression is used to insert the value of a scripting language expression, converted into a string, into the data stream returned to the client using response object.

The syntax for an expression is as follows:
<%= scripting-language-expression %>

Example of JSP expression Tag :
On index.jsp, user enters name that send as request to user.jsp which prints username as output.

index.jsp
   <html>   
   <body>   
      <form action="user.jsp">   
        <input type="text" name="username">   
        <input type="submit" value="Submit"><br/>   
      </form>   
   </body>   
   </html>   

user.jsp
   <html>   
   <body>   
       <% ="Welcome! "+ request.getParameter("username") %>     
   </body>   
   </html>   

Write a program to draw Pyramids using nested for loops in java

We are providing here code for drawing 6 Pyramids with the help of inner or nested for loops in Java.

Code :
 public class PrintPyramid {  
      public static void main(String args[])  
      {  
           //Pyramid One  
           for(int i=1;i<=5;i++)  
           {                 
                for(int j=1;j<=i;j++)  
                     {  
                          System.out.print("@ ");  
                     }  
                System.out.println();  
           }  
           //Pyramid Two  
           for(int i=1;i<=5;i++)  
           {                 
                for(int j=1;j<=5-i;j++)  
                     {  
                          System.out.print("# ");  
                     }  
                System.out.println();  
           }  
           //Pyramid Three  
           for(int i=1;i<=5;i++)  
           {                 
                for(int j=1;j<=5-i;j++)  
                     {  
                          System.out.print(j);  
                     }  
                System.out.println();  
           }  
           //Pyramid Four  
           for(int i=1;i<=5;i++)  
           {                 
                for(int j=1;j<=i;j++)  
                     {  
                          System.out.print(i);  
                     }  
                System.out.println();  
           }  
           //Pyramid Five  
           for(int i=1;i<=5;i++)  
           {                 
                for(int j=1;j<=5-i;j++)  
                     {  
                          System.out.print(" ");  
                     }  
                for(int k=1;k<=i;k++)  
                {  
                     System.out.print("% ");  
                }  
                System.out.println();  
           }  
           //Pyramid Six  
           for(int i=1;i<=5;i++)  
           {                 
                for(int j=1;j<=5-i;j++)  
                     {  
                          System.out.print(" ");  
                     }  
                for(int k=1;k<=i;k++)  
                {  
                     System.out.print("$ ");  
                }  
                for(int l=1;l<i;l++)  
                {  
                     System.out.print("$ ");  
                }  
                System.out.println();  
           }  
      }  
 }  
Output :