Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Java Beginners Triangle

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

26 comments so far (post your own) View All Comments Latest 10 Comments:

can you help me in java to understand loop?

Posted by Asif Saqi on Friday, 10.15.10 @ 22:28pm | #100308

1
12
123
1234
12345

Posted by saru on Tuesday, 08.17.10 @ 22:11pm | #99006

show me the program which prints like


*****
***
*

Posted by MANIKANTA on Wednesday, 06.30.10 @ 19:20pm | #97870

Its good for beginner
read every line and understand the logic then U will be a GOOD LEARNER in corejava.

Posted by shaik.jaid on Wednesday, 06.2.10 @ 16:42pm | #97336

very very nice step by step tutorial keep it rocks

Posted by hi on Tuesday, 06.1.10 @ 12:10pm | #97305

Thanks,for giving these kind of information that is related to the java programming. This site also give theory related to the program. That is maassive.

Posted by Gaurav on Tuesday, 03.23.10 @ 11:50am | #95768

*
* *
* * *
* * * *




i want this program code

Posted by chaitanya on Tuesday, 02.16.10 @ 11:48am | #94872

I would like to know how to write a program in Pascal programmng Langauge to calculate Area of the Triangle.

Posted by Mwache on Wednesday, 02.3.10 @ 13:52pm | #94543

thank you

Posted by eba desalegn on Tuesday, 12.15.09 @ 23:46pm | #93401

Hello I need help with these two java programs, by the way I'm just a beginner. Now here's my problem.

0
90
890
7890
67890
567890
4567890
34567890
234567890
1234567890

can sommebody help me with with the code I don't know how to start with te number 9, and how to put 0 on every end of the line.

here is my second problem.

123454321
1234321
12321
121
1
Please I really need help.
Thanks ^_^

Posted by Sorb3t3ro on Thursday, 10.29.09 @ 05:33am | #92179

this program doesnt give a triangle. all the asteriks are on a straight line instead of it to be arranged in a triangular form.

There should be a System.out.println(" ");(This would be the 14th line)
and on the 13th line it should be system.out.print not system.out.printLN (I kept the "LN" in capslock just to highlight it)

So the program should look like this

import java.io.*;

class triangle{
public static void main(String[] args) {
try{
BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the number");
int a= Integer.parseInt(object.readLine());
for (int i=1; i<a;i++ ){
for (int j=1; j<=i;j++ ){
System.out.print("*");
}
System.out.println("");
import java.io.*;

class triangle{
public static void main(String[] args) {
try{
BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the number");
int a= Integer.parseInt(object.readLine());
for (int i=1; i<a;i++ ){
for (int j=1; j<=i;j++ ){
System.out.print("*");
}
System.out.print("");
System.out.println(" ");
}
}
catch(Exception e){}
}
}
}
}
catch(Exception e){}
}
}

Posted by mkab on Wednesday, 09.16.09 @ 17:44pm | #90976

i need aprogram to print a triangle with *
* *
* * *
* *
*

Posted by shunmuga arthi on Wednesday, 07.8.09 @ 21:46pm | #89171

its hard to do this program can you an example of code of this.....
*
* *
* * *

Posted by jayce on Monday, 03.23.09 @ 20:30pm | #86140

What is the explanation of the following program?

class TwoDArray {
public static void main(String args[]) {
int twoD[][]= new int[4][5];
int i, j, k = 0;
for(i=0; i<4; i++)
for(j=0; j<5; j++) {
twoD[i][j] = k;
k++;
}
for(i=0; i<4; i++) {
for(j=0; j<5; j++)
System.out.print(twoD[i][j] + " ");
System.out.println();
}
}
}

Posted by Navin on Monday, 03.23.09 @ 06:19am | #86126

using single for loop u have to display the stars4YGM

Posted by sravan kumar on Wednesday, 02.18.09 @ 11:16am | #84989

Thanks for the triangle program. and i need help to solve the problem with output like below.

ABCD DCBA
ABC CBA
AB BA
A A

Thanks

Posted by Kiran on Sunday, 02.8.09 @ 01:21am | #84610

i want the stars in numbers

like
1
12
123
1234

then how to reverse this

Posted by vani on Thursday, 02.5.09 @ 15:22pm | #84535

*
* *
* * *

Posted by Adithya on Thursday, 01.22.09 @ 13:08pm | #84074

how java can be faster in doing

Posted by rozel on Thursday, 11.27.08 @ 00:05am | #82086

******
*****
****
***
**
*
It is taking the input Eg : 6 from the user
Then In the integer there is a method called ParseInt with the help of the parseInt the for loop is been executed if a= 6 then i=6 & j=1 then the o/p will be ****** if i++ & J++ the loop will be reduced one by one

Posted by Kathiravan J on Tuesday, 09.2.08 @ 17:50pm | #76792

how can u print this tringle:

*
***
*****
*******

Posted by ernest on Thursday, 07.31.08 @ 13:37pm | #70102

I want to print triangle in this formate
1
21
321
4321
plz help me

Posted by pavan on Friday, 06.6.08 @ 14:50pm | #62325

prog for * * * *
* * *
* *
*
code for printing the above triangle

Posted by gyanendra on Thursday, 02.28.08 @ 12:57pm | #50391

Dear sir,
could you explain me clearly about the working of for loop for the above example?

Posted by Preetha on Friday, 01.18.08 @ 09:48am | #45494

hay as the program is meant for printing the
no.of. time a star according to the user input
in the loop u got to put equals only then it
give such output otherwise it gives u wrong
for
eg:
if user input is 5 then 4 star prints
so the loop should be (for int i=0;i<=a;i++)

Posted by Gunaranjan on Monday, 12.17.07 @ 09:15am | #42677

prog for * * * *
* * *
* *
*
code for printing the above triangle.

Posted by chinni on Thursday, 10.18.07 @ 18:29pm | #34336

Ask programming questions?

 

 

Back to Tutorial

 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.