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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does every java program need a main?

529


What are unchecked exceptions in java?

604


Is java owned by oracle?

516


What is finalize() function in java?

550


Can java object be locked down for exclusive use by a given thread?

573






In java, how we can disallow serialization of variables?

544


What is the final access modifier in java?

608


Explain the difference between call by refrence and call by value?

555


What is main difference between variable and constant?

517


What is ellipsis in java?

570


Write a program in java to create a doubly linked list containing n nodes.

549


How do you decide when to use arraylist and linkedlist?

526


How to check if linked list contains loop in java?

445


What are the differences between processes and threads?

505


Why do we use bufferedreader?

524