Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java triangle

import java.util.Scanner;

public class triangle {
    public static void main(String[] args) {
        Scanner userInput = new Scanner(System.in);
        int n = userInput.nextInt();
        for (int row = 0; row < n ; row++) {
            for (int i = 0; i < row ; i++) {
                System.out.print(".");
            }
            for (int i = 0; i < n-row ; i++) {
                System.out.print("*");
            }
            System.out.println();
        }

    }
}
Comment

how to draw a triangle in java

graphics.drawPolygon(new int[] {10, 20, 30}, new int[] {100, 20, 100}, 3);
// Graphics.drawPolygon(x-coordinates, y-coordinates, # of points);
Comment

PREVIOUS NEXT
Code Example
Java :: what method is use for getting the index position of a character of a string in java 
Java :: java % 
Java :: java camel case 
Java :: play mp3 android java 
Java :: on touch listener android 
Java :: max of an array java 
Java :: java 8 datediff in days 
Java :: java method return list 
Java :: remove last <br/ from string java 
Java :: java remote debug 
Java :: java dynamic method dispatch 
Java :: printing 2d array in java 
Java :: filter arraylist java 
Java :: operador ternario java 
Java :: split number java 
Java :: initialize scanner java 
Java :: how to check null and empty string in java 
Java :: Add delay to code in Android 
Java :: number of digits java 
Java :: isanagram java 
Java :: java first letter to upper case 
Java :: Java Create ArrayList in Java 
Java :: iterate through an arraylist java 
Java :: sort list java 8 
Java :: java android edit text set value 
Java :: classcastexception in java 
Java :: queue in java 
Java :: java protected private public 
Java :: setbackground color hexadecimal android 
Java :: java get attributes from class 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =