answersLogoWhite

0


Best Answer

public class Traingle {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

char c=' ';

for (int i=0; i<4; i++)

{

for (int k=0; k<6-i; k++)

{

System.out.print(" ");

}

for (int j=0; j<i*2+1; j++)

{

System.out.print("*");

}

System.out.println(c);

}

}

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Using for loop print the stars in the shape of equilateral triangle in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the use of base keyword?

Using base in a derived class invokes the base class's corresponding method. For example, something like: class Shape{ public void print(){printf("Generic shape"); ... } class Triangle:Shape{ public void print(){printf("Triangle"); ... } int main() { Triangle x; x.print(); // Should print "Triangle" x.base.print(); // Should print "Generic shape" return 0; }


Is a triangle a tessellate?

Sort of. Triangle is one of the shape that may tessellate(fit tightly). But one may argue that triangle is not a square (for sure), nor a tile (yet I think it may be) to a tessellate.


What shape is predominant in bridge building?

triangle for small parts and an arch for a large part.


What is the difference between size and shape of an object?

When referring to size, something can be very small or very big. When referring to the shape, an item can be round, square, or even a triangle.


What is the difference between an actual type and declared type variable?

I believe a declared type is the type used when first declaring a variable. And the actual type is the type that the variable is actually assigned, which could be the declared type or any subtype of that type. So given GeometricObject shape = new Triangle(); GeometricObject is the declared type and Triangle is the actual type. To demonstrate this more clearly the following statements are all correct. GeometricObject shape; // shape declared to be a GeometricObject shape = new Triangle(); // actual type assigned = Triangle shape = new Square(); // now shape refers to a Square object This is the basis of polymorphism. It allows you to write methods which have for parameters more general types but are able to handle subtypes differently. This makes your code more general and reusable.