Home / JAVA (page 6)

JAVA

Java program for string in circular fashion.

Write a program to input any string and output it in the following format:  hello elloh llohe lohel ohell   class circularstring { public static void main(String args[]) { String str=args[0],p,s=""; int i,j; for(i=0;i<str.length();i++) { p=str.substring(i,l); s=str.substring(0,i); System.out.println(p+s); } } } OUTPUT:   hello elloh llohe lohel ohell Tags: java program for circular string, bluej program for circulating the string ...

Read More »

java program for pattern#6

Java program for printing the following pattern: * *** ***** ******* This program also have indentation. Indentation required depends on the output needed and here indentation requires is: for row 1:  total 4 spaces and then 1 start row 2: total 3 spaces and 3 stars row 3: total 5 spaces and 5 stars……. So on  So here spacing is ...

Read More »

java program for pattern#12

Java program for pattern with indentation or spacing 1 12 123 1234 This is a simple java program for pattern with indentation. Indentation in pattern is thus required. This can be done using extra for loop to provide the required indentation per line. Also Check: Alternate C program for this pattern #12 class format4 { public static void main(String args[]) ...

Read More »

java program for pattern with indentation

 java program for pattern making      1    21   321 4321   This is a simple java program for pattern with indentation. Indentation in pattern is thus required. This can be done using extra for loop to provide the required indentation per line. ALSO CHECK:  Alternate c program for this pattern class format3 { public static void main(String ...

Read More »

java program for pattern#8

 java program for pattern making: 1 12 123 1234 This is a simple pattern in java where you have 4 rows: Now the columns are dependent on number of rows. For 1st row there is only 1 element or 1 column. For 2nd row there are 2 elements or 2 columns For 3rd row there are 3 elements or 3 ...

Read More »

Java program for patterns and formats in java/bluej/c/c++

Java Program for format/pattern making in java/ Bluej 1 23 456 78910 This pattern is also called floyd’s triangle. You can also see Floyds triangle for N rows where n is inputted by user: Java program for floyd’s triangle class format1 { public static void main(String args[]) { int i,j,k=1; for(i=1;i<5;i++) // This loop is For number of rows -5 ...

Read More »

java program for eliminating the multiple characters occurring in a string using string buffer functions

This java program is for eliminating repeated characters in a string step by step. class frequency{public static void main(String s){int i,z=0,max,k,j,c=0,L,a=0;L=s.length();String s1=s.toLowerCase(); // eliminating charachters can be both in uppercase and lower case this program treats both the case similarly.if(s1.charAt(0)==s.charAt(0))z=1;for(k=0;k

Read More »

Java program to find saddle point in a matrix

Saddle point- it is that element in a matrix when it is smallest in a row and largest in the same column it exist. There can be multiple saddle points and zero saddle points in a matrix. Here is a java program for you in BlueJ / Java for saddle point. import java.io.*; class saddle { public static void main(String ...

Read More »

Multiple Inheritance in JAVA

This is the program to show multiple inheritance in Java. Actually JAVA doesn’t support any multiple inheritance but in this program we made a trick by using a extended class and interface which seems that program using multiple inheritance.  class student //program in java to show multiple inheritance { int rollNumber; void getNumber(int n) { rollNumber=n; } void printNumber() { ...

Read More »

Program for string in cross x format on given position

Program for string in x format on given contact position in the middle of your output screen  class formatx { public static void main(String s,int n) { int i,j,k,l=s.length(); char a[][]=new char[l*l][l*l]; j=l/2; for(i=0;i<15-j;i++) System.out.println(); for(i=0;i<l;i++)< span=""> a[i][l+i]=s.charAt(i); j=l+n; k=n-2; for(i=n-2;i>-1;i--) a[i][j++]=s.charAt(k--); j=l+n-2; k=n; for(i=n;i<l;i++)< span=""> a[i][j--]=s.charAt(k++); for(i=0;i<l;i++)< span=""> { for(j=0;j<65-l-n;j++) System.out.print(' '); for(j=0;j<l*3;j++)< span=""> { if(a[i][j]!=0) System.out.print(a[i][j]); else System.out.print(' ...

Read More »