Comment

mkab
Dear Sir,
September 16, 2009 at 5:44 PM

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){}
}
}
View All Comments | View Tutorial
Related Tutorial and Articles
Development process Questions

Dear Sir I need to join u
Dear Sir I need to join u  Dear Sir i am santosh Rai from Saudi Arabia please make me understood how to join u and i have one question i want to working with you what is ur process for working with u please send me 

Java Beginners

hi sir - Java Beginners
hi sir  Hi,sir,i am try in netbeans for to develop the swings,plz... the details sir, Thanks for ur coporation sir  Hi Friend, Please visit the following link: http://www.roseindia.net/java/java-tips 

Java Beginners

sir - Java Beginners
sir   hi sir,in this program there is a jtable,i am insert... sir,i am mentioning the error as <<>>>......main bug here>........ in this program,plz see and provide solution sir,database Tables 

Java Beginners

sir - Java Beginners
sir   hi sir,Happy ugadi,how to place the database records into jtable ,i am using the oracle database plz provide the program how to retrieve the database records and placed into a jtable,i want one more column is added to my 

Java Beginners

sir - Java Beginners
 

Java Beginners

more doubts sir. - Java Beginners
more doubts sir.  Hello sir, Sir i have executed your code and i got the result but the problem is whenever i click on the link in my... own browser.Hope you will help me out.And also sir i need the progressbar 

Java Beginners

TRIANGLE OF *S AT THE BOTTOM RIGHT!!! - Java Beginners
TRIANGLE OF *S AT THE BOTTOM RIGHT!!!  My Question is to : "Write a program that inputs one integer m and outputs an m-line high triangle of *'s... to make the triangle at the right side but couldn't do so. Can you please solve 

Java Beginners

swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert 

Java Beginners

Triangle program
Triangle program  1 121 12321 1234321 123454321 kindly give the code 4 this program in java    1 121 12321 1234321 write a program for this triangle    1 121 12321 1234321 write a program 

Java Beginners

Hello Sir I Have problem with My Java Project - Java Beginners
Hello Sir I Have problem with My Java Project  Hello Sir I want Ur Mail Id To send U details and Project Source Code, plz Give Me Ur Mail Id 

Java Beginners

please do respond to my problem sooooon sir - Java Beginners
please do respond to my problem sooooon sir  Hello sir, Sir i have... to open the link also in my own browser.Hope you will help me out.And also sir i need... for more information. http://www.roseindia.net/java/ Thanks 

Java Beginners

hello sir, please give me answer - Java Beginners
hello sir, please give me answer  Write a program in Java that calculates the sum of digits of an input number, prints... ways in java? so , sir please tell me full solution of this program   Here is your complete 

Java Beginners

sir plz do respond to my problem immediately - Java Beginners
sir plz do respond to my problem immediately  Hello sir, Iam very happy that you have responded to my problem.The code u sent for the progree bar is a separate program. sir i need to put it in my web browser.sir iam 

Java Beginners

java code - Java Beginners
java code   Dear Sir i need code for the following... * * * * * * * * * * * * * * * This is called Equilateral triangle   Hi...://www.roseindia.net/java/ Thanks.    Hello Please try the following code may 

HTML Questions

triangle
triangle  how to draw triangle numbers with stars in html with the help of javascript 

Java Beginners

how to perform a equqlity triangle in java
how to perform a equqlity triangle in java  below the output 1 2 3 4 6 5 7 9 10 8 

Java Beginners

java code - Java Beginners
java code  Dear sir i need one java code * * * * * * * * * * * * * * * this model only i dont want need... public class Triangle { public static void main(String[] args) { for(int 

Java Beginners

Java draw triangle draw method?
Java draw triangle draw method?  hi how would i construct the draw method for an triangle using the 'public void draw (graphics g ) method? im...; Here is an example that draws a triangle using drawPolygon method. import 

Java Beginners

triangle
the sides of a triangle If they can form a triangle, determine and print if they can also form the sides of a right-angle triangle The class should include proper data 

Java Code Examples

Java create triangle pattern
Java create triangle pattern In this tutorial, you will learn how to create a triangle shape. For this, user is allowed to enter number of lines to display the triangle of that length and a symbol to show the triangle in a particular 

Java Beginners

how to perform a equqlity triangle in java
how to perform a equqlity triangle in java  below the output 1 2 3 4 6 5 7 9 10 8   Here is an example of pattern like 1 2 3 4 5 6 7 8 9 10 Example : public class NumberTriangleClass{ public static void 

General

How to calculate area of triangle
of triangle. Description of this program  This is very java programming... Area of Triangle       In this section we will learn how to calculate area of triangle. We 

Java Beginners

A Program To Print A Equilateral Triangle
A Program To Print A Equilateral Triangle  Write A program to Print Following In Java : 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

Java-Tutorials

Java Program Floyd's Triangle
Java Program Floyd's Triangle In this section you will read about how to write a Java program to print Floyd's triangle. This tutorial is about printing a Floyd's triangle in Java. Here you will learn about all the steps 

JavaMail Questions

sir i,have a assignment for these question plz help me sir - JavaMail
sir i,have a assignment for these question plz help me sir   1.Design a Java interface for ADT Stack. Develop two different classes... class hierarchy in Java. Write a test program to demonstrate polymorphism   

Java Tips and Examples

Write a program to construct a triangle with the ?*?
'*'. First of all make a class named 'triangle' under the Java I/O package... Write a program to construct a triangle with the ?*?       This lesson in Java 

Java Beginners

Java Basics - Java Beginners
Java Basics   Dear Sir/Madam, Is Array Static? If Yes How can we say Array is static? Thanks and Regards, M.KethraBalan@Arumugam 

Java Beginners

install - Java Beginners
install  Dear Sir, How to install java on Windows 98 Or What is command to Set java path on COMMAND PROMPT 

Java Beginners

sir plz send the project on quiz system code
sir plz send the project on quiz system code  sir plz send the client server based project in core java database in my sql 

Java Beginners

cloning - Java Beginners
cloning  Dear Sir, Can you send a simple java program for CLONING an object 

JavaMail Questions

i have problem in that program sir - JavaMail
i have problem in that program sir  1.Develop multi-threaded echo server and a corresponding GUI client in Java 

Java Beginners

Java Certification - Java Beginners
sun java certification details  Dear Sir, I want to do a java certification test. So, what I do for that?  Hi Are you interested in SCJP or SCWCD. If you are interested in first level that is SCJP then try following 

Java Beginners

Java Programs - Java Beginners
Java Programs  Dear Sir, Could you give me the syntax for HIERARCHIAL INHERITANCE and give sample program for the same?(if possible with an output...://www.roseindia.net/java/language/inheritance.shtml Thanks 

Java Beginners

java code - Java Beginners
java code  Dear sir i need matris form like 1 2 3 4 5 6 7 8 9 what is the code but one request use one loop only any thing forloop.... http://www.roseindia.net/java/beginners/SquareMatrix.shtml Thanks 

Java Beginners

java - Java Beginners
java  dear sir, plz give me a java code where we copy a files from a folder and paste in a single file by zip, and again open the all files in a single file 

JavaMail Questions

sir i,have a another assignment for these question plz help me sir - JavaMail
sir i,have a another assignment for these question plz help me sir  ... a scientific calculator using event-driven programming paradigm of Java. 3. Write a multi-threaded Java program to print all numbers below 100,000 

Java Beginners

Java - Java Beginners
Java  Dear sir/madam Suppose i have a doc file. I need to print some text from source file which is red color text to output file. My question is "how i can sort that particular text in output file"? Regards 

Java Beginners

java program - Java Beginners
java program  what is the program the a simple program in Java... of the triangle and then the program; a)First determines whether the 3 integers entered represent the sides of a right-angled triangle, equilateral triangle, isosceles 

Java Beginners

java - Java Beginners
java   Dear sir, I have made an application using java and want to make it run on other machine, as we know java based applications dont run untill we install JRE, so is there any way to run java application without having JRE 

Java Beginners

Java application - Java Beginners
Java application  Dear sir, I Designed a Window Throung Swing component Using JDBC. My Problem is that How and What component may used... the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml Hope 

Java Beginners

java coding - Java Beginners
java coding  dear sir, i'm doing a java coding using with netbeans ide, so i'm trying to pass some text from one jframe to another jframe which is both are already opend on screen then how to do it? please send me 

Java Beginners

JAVA PROJECT - Java Beginners
JAVA PROJECT  Dear Sir, I going to do project in java " IT in HR, recruitment, Leave management, Appriasal, Payroll" Kindly guide me about programming, Database selection (sql or mysql) which is going to work on networking 

Java Beginners

JAVA - Java Beginners
JAVA  Dear Sir, Kindly arrange to send urgently the answers to the following in JAVA rega1.JAVA rding True or False, please. 1. JAVA is pure object oriented Language .. True/False 2. Private number of your Class 

Java Beginners

JAVA - Java Beginners
JAVA  JAVA Expert:N.SATHYANANDA Dear Sir, Kindly arrange to send urgently the answers to the following One Question in JAVA regaarding True or False, please. 1. Private Member of a Class can be accessed by its Sub 

Java Beginners

LUNIX - Java Beginners
LUNIX  Dear Sir, Kindly send some important points in LUNIX since I have taken the exam pertains to LUNIX, so that it will be very helpful for getting more marks. Thnking you, (N.SATHYANANDA 

Java Beginners

JAVA - Java Beginners
JAVA  Dear Sir, Kindly guide me the definitions in short form (4 to 5 lines) for the following in JAVA, please. 1.Layout Manager 2.Dynamic Method Dispatch 3.Thread Synchronization 4.Abstract Class 5.Over riding methods 

Java Beginners

triangle output
triangle output  program to get the following output 

Java Beginners

Multilevel inheritance - Java Beginners
Multilevel inheritance  Dear Sir, I'm posting you another question for which I need a more explanatory java coding(A lengthy one with more classes if possible) "Write a java program to create simple student object and inherit 

Java Beginners

about swings - Java Beginners
about swings   Dear sir,Good evening, i am doing mca sir,i am doing the project in swings,so plz provide the material about swings sir...: http://www.roseindia.net/java/example/java/swing/ Hope 

Java Beginners

Java Project - Java Beginners
Java Project  Dear Sir, Right now i am working in java image..., Please visit the following links: http://www.roseindia.net/java/example/java/swing/color-effect-image.shtml http://www.roseindia.net/java/example/java 

Java Beginners

Java Project - Java Beginners
Java Project  Dear Sir, I have to do Project in "IT in HR i.e. Recruitment, Leave Management, Appraisal & payroll. These are Four main modules... employee master. Now, can you tell in Java programming with Mysql How can 

Java Beginners

java beginners - Java Beginners
java beginners   the patteren u received is not the actual patteren... in proper formate to you . it was in upside down triangle form . at the top... 'a' will be moving towards left forming a triangle . id possible tell me how 

Java Beginners

Java - Java Beginners
Java  Dear Sir, I am working image searching in java project , in that i have to split one image like texture , color , shape then after that i have to store that details in Data Base.Finally if i give any picture [any 

Java Beginners

JAVA - Java Beginners
JAVA  Dear Sir, Kindly provide full answer for the question " Write a program to catch exception ? Please (N>SATHYANANDA...://www.roseindia.net/java/exceptions/catching-and-handling-exceptions.shtml 

Java Beginners

RASTER TRIANGLES!!! - Java Beginners
RASTER TRIANGLES!!!  Hi Sir, Sorry i think in my previous post, I... of right angle triangle starting from left side on the screen as you can see below... if i want to make this kind of triangle 4 times in the same row where 

Java Beginners

code problem - Java Beginners
code problem  Dear sir, my problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz 

Java Beginners

WEBLOGIC - Java Beginners
WEBLOGIC  DEAR SIR, HOW TO RUN THE PROGRAMS IN WEBLOGIC AND TELL HOW TO GIVE ENVIRONMENTAL PATH IN CPNTROLPANNEL.   Hi Friend, Please visit the following link: http://www.roseindia.net/javabeans/javabeans.shtml 

Java Beginners

program - Java Beginners
: * ** *** **** ***** **** *** ** *   sir i have tried it out...u just... is not coming.. see my program... import java.io.*; class triangle... java.io.*; public class triangle { public static void main (String[] args 

Java Beginners

install - Java Beginners
install  Dear Sir, How to install java on Windows 98 Or What is command to Set java path on COMMAND PROMPT.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/learn-java-in-a-day/download 

Development process Questions

Triangle pgm
Triangle pgm  how to write code fa this??? 1 222 33333 4444444 55555555 666666666 

Java Beginners

triangle output
triangle output  program to get the following output: * *   Hi Friend, Please specify the pattern properly. Thanks 

Development process Questions

pascal triangle
pascal triangle   given string : char str[]="123456789"; write a program in 'c'-language that displays the following: 1 232... the following link: C Pascal's Triangle Thanks 

Travel

India Golden Triangle Tours With Udaipur
India Golden Triangle Tours With Udaipur Duration: 07 Nights / 08 Days Destinations : Delhi-Agra-Jaipur-Udaipur Day 01: Arrival-Delhi On Arrival... Sir Edwin Lutyens. Visit the India Gate in vicinity and never miss 

Java Beginners

Code for a triangle.....
Code for a triangle.....   1 1 5 1 1 5 25 5 1 What is the source Code for above output 

Java Beginners

JAVA - Java Beginners
JAVA  Dear Sir, Kindly guide me the correct answeres for the following True or False. 1.Variables can be declared in Constructor. 2.A Constant can be declared in Constructor. 3.Private numbers of a class can be accessed 

Java Beginners

code problem - Java Beginners
code problem  Dear sir, i'm making a program where characters of a string are being displayed having its length thru a loop, like- s a t i s... u very very much sir i got satisfied answer. thnxxxxxxxx once again sir 

Java Beginners

Java Compilation - Java Beginners
Java Compilation  Dear Sir, Thanks for giving the code for the question which i posted. I went through the program "Write a Java program to read... it as simple java code. Thanks 

Java Beginners

J2EE - Java Beginners
J2EE  Dear Sir, Right now i am working as a java programmer and i have to learn for J2EE. Which book is good for learning JSP, SERVLETS,EJB,HIBERNATE,SPRINGS,STRUCTS,XML and JSF. and which area i have to concentrate 

Java Beginners

Java Compilation - Java Beginners
Java Compilation  Dear Sir, Could you please send me the program code for the following java program? Q:Create a classname Math with its required variables and use add(),sub(),multiply(),divide(),modulo() methods? Thank 

Java Beginners

Triangle problem
Triangle problem  what's the logic for create pattern program how can i create any pattern program with in minute. like this 1 2 5 3 6 8 4 7 9 10 

JavaMail Questions

i have problem in that program to my assignment sir - JavaMail
i have problem in that program to my assignment sir   Develop a programmer's editor in Java that supports syntax-highlighting, compilation support, debugging support, etc 

Java Beginners

how to write a program in java to print numbers in equalateral triangle
how to write a program in java to print numbers in equalateral triangle  the output must be 1 324 76589   Here is an example of pattern 1 2 3 4 5 6 7 8 9 Example: public class NumberTriangle{ public 

Java Beginners

Triangle Program
Triangle Program  i want program code for 1 2 3 4 5 6 7 8 9 10 any body please help me   public class Triangle { public static void main(String[] args 

Java Beginners

java compilation error - Java Beginners
java compilation error  Dear Sir ........ I was installed the java soft ware in PC by following your guidelines only, after installing I'm... Shireesha.  Hi Friend, As you have mentioned that your java file 

Java Beginners

code problem - Java Beginners
code problem  Dear sir, I want to print some line with (") this sign,like: output should come ("hello world") instead of (hello world) thnx  hi friend, If you want to print "hello world",you have to use 

Java Beginners

code problem - Java Beginners
code problem  Dear sir, My problem is that i have some string value and in some case i want to remove all the value of this string, i tried this code- Response.str.clear(); but it shows some error called "response package 

Java Beginners

Project Concerning - Java Beginners
Project Concerning  Dear Sir, Can you write me URL of any website from where I study the Servlet, JSP project.   Just googled it n im sure u will get many more results. Otherwise, RoseIndia is a better option 

HTML Questions

hii sir
 

Java Beginners

java Date - Java Beginners
java Date  Dear sir I have an assignment, It is .. "Develop Date class in java similar to the one available in java.util package.Use JavaDoc comments " Please help me to do the assignment, and tell me the steps 

Java Beginners

String and StringBuffer - Java Beginners
String and StringBuffer  Dear Deepak Sir, What is String... information. http://www.roseindia.net/java/beginners/StringBuffer.shtml...; Hi vijay Java provides the StringBuffer and String classes 

Java Beginners

Rental Code GUI - Java Beginners
Rental Code GUI  dear sir... i would like to ask some code of java GUI form that ask the user will choose the menu to input Disk #: type... the Credit card #: bank: under the Cash Discount: that's all sir 

Java Beginners

Interface - Java Beginners
Interface  Dear Sir, Could you send me a java program for INTERFACE? Thank You.  Hi Friend, Try the following code: import...://www.roseindia.net/java/master-java/interface.shtml Thanks 

Java Beginners

triangle shape
triangle shape  Hi, I have to create a program which its output is: + ++ +++ ++++ and this what I did so far : package symbols; import java.util.*; public class Symbols { public static void main(String[] args) { Scanner 

Java Beginners

compilation error - Java Beginners
compilation error  Dear sir, When i compile some pgms i am getting below error.what may be the reason? "uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details."  Hi Friend 

Java Beginners

code problem - Java Beginners
code problem  Dear sir, my question was actually how to find a particual line's contain, example if a file contains- hy, how r u? regrd, john! how will i find what contain a particular line carries? output should 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

JAVA - Java Beginners
JAVA  Dear Sir, Kindly guide me the definitions in short form (4 to 5 lines) for the following in JAVA, please. The answer is required very much urgent since I have to attend for the exam in JAVA. It would be very helpful 

Java Beginners

core java, static - Java Beginners
core java, static  Dear sir, in java non-static fields can not be accessed in a static field. But if we create an object of class type in static field and then call non-static field in it, it works fine as in following program 

Development process Questions

sir, how to convert excel file to csv file using java? please send me sample code.
sir, how to convert excel file to csv file using java? please send me sample code.  please send me sample code for converting excel file into csv file uisng java 

Java Beginners

Java program - Java Beginners
Java program  Dear maam/Sir, I am a 2nd year Computer programming student and we are given an assignment, a program that will show... not that familiar with java environment.. My friend told me that you can help me with my 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge 

Java Beginners

java - Java Beginners
java  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism 

Java Beginners

code problem - Java Beginners
code problem  Dear sir, I've some integer value in ArrayList like- 10 40 30 i want to add them and print should be like- "total value is = "80" plz help me i tried my best but i could not make out this type 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles