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 is static setter and getter examples in java 
Java :: use of randomAccessfile() in java 
Java :: how to addin java 
Java :: pass array to method java 
Java :: java string vers int 
Java :: spring security logging 
Java :: Java get color from rgb values 
Java :: stringbuilder java 
Java :: java creating a stack 
Java :: interface extending interface in java 
Java :: return two values in java 
Java :: android handler clear message queue 
Java :: java.lang.NoClassDefFoundError: 
Java :: mongodb check if field exists java 
Java :: pass a list of string as PathVariable to api spring boot 
Java :: sorting methods in java 
Java :: how to convert infix to postfix and prefix in java 
Java :: java require non null 
Java :: Number formatting java with locale 
Java :: student information using array of object java 
Java :: algorithm to know if a number is an integer 
Java :: android java how to stop activity from opening twice programatically 
Java :: Unexpected end of file in android studio activity main.xml 
Java :: check if two lists are equal java 
Java :: Send keybord key P in selenium java 
Java :: change brightness of image in java 
Java :: Java Access ConcurrentHashMap Elements 
Java :: java resultset to table 
Java :: java calendar to date 
Java :: How do I make my Android app scrollable? 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =