Hi friends i want display Triangle shap stars(*) please can
tell me any one java code logic?
*
***
*****
******* Like this

Answers were Sorted based on User's Feedback



Hi friends i want display Triangle shap stars(*) please can tell me any one java code logic? ..

Answer / sadikhasan palsaniya

public class Test{
public static void main(String var[]){
int c=1;
for(int i=1;i<=4;i++){
for(int k=4;k>=i;k--)
System.out.print(" ");
for(int j=1;j<=c;j++){
System.out.print("*");
}
System.out.println("");
c=c+2;
}
}
}

Is This Answer Correct ?    14 Yes 5 No

Hi friends i want display Triangle shap stars(*) please can tell me any one java code logic? ..

Answer / royal

Thanks Sadik............

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More Core Java Interview Questions

I have a sorting issue with a Hashmap. My constraint is that I MUST use the Hashmap and work with existing code. I do a database query and place the results in a Hashmap. When I iterate thru the Hashmap, it loses the original alphabetical sorting done by the database. So, my problem is that I must sort the results coming out of the Hashmap which is then placed into another class.

1 Answers  


C and C++ has constructors and distructors, why does Java does not have distructors?

1 Answers   T3 Softwares,


Write java code to print "Hello how are you" Thread1 should have "Hello" Thread2 should have "how are you" both the threads should start at the same time

4 Answers   Huawei,


Which of these methods belong to Thread & Object class? join, yield, sleep, wait, notify

3 Answers   Ericsson,


how can u handle run time exception in java? explain with brief explanation with examples?

2 Answers   CTS,






Write a program to show whether a graph is a tree or not using adjacency matrix.

0 Answers   Amazon,


What is the difference between static synchronize() metod and synchronize() method?

1 Answers   Polaris,


What does java stand for?

0 Answers  


What is tcp and udp?

0 Answers  


What is not thread safe?

0 Answers  


What is complexity in java?

0 Answers  


How to sort numbers in java without array?

0 Answers  


Categories