Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Print Positives of array

import java.util.Scanner;
public class PrintPositives {
    public static void main(String[] args) {
        System.out.println("Enter size of array ");
        Scanner input = new Scanner(System.in);
        int arr = input.nextInt();
        int[] numbers = new int[arr];
        for (int i = 0; i < numbers.length; i++) {
            System.out.println("Please enter number");
            numbers[i] = input.nextInt();
        }
        System.out.println("positive numbers");
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i]>=0){
                System.out.println("positive" + "-" + numbers[i]);
            }
        }
    }
}
Comment

Print positive numbers from array

public class NumPositives {
    public static void main(String[] args) {
        double a[] = {-4,5,7,-9};
        System.out.println("positive numbers");
        for (int i = 0; i < a.length; i++) {
            if (a[i]>=0){
                System.out.println("positive" + "-" + a[i]);
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java 8 iterating and manipulating list 
Java :: Method Overloading by changing the data type of parameters Java 
Java :: Java public no-arg constructor 
Java :: netbens setdefaultbutton 
Java :: Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (execution: default-compile, phase: compile) 
Java :: madrid 
Java :: assign a random number in a set without replacement javva 
Java :: show menuitem when menu hovered javafx 
Java :: show bottom sheet in adapter 
Java :: java method overloading 
Java :: square oot of 154 
Java :: add new item to array java 
Java :: list in list 
Java :: gson to class 
Java :: java load configuration log 
Java :: java %2C 
Java :: Java public no-arg constructors 
Java :: print method in java 
Java :: size of a tree node java linked;ist 
Java :: output of java file in terminal 
Java :: gradle project load test data json file with jackson 
Java :: oxygen cylinder management program in java 
Java :: java stream anymatch vs findany 
Java :: how to get data from array list to set java 
Java :: Period java springboot 
Java :: repository null when testing service 
Java :: how to decode a ByteArray to Bitman in adroid 
Java :: infinity constant in java 
Java :: what singleton java spring 
Java :: how to check that letter is not a number and is repeating or not in a sentence in java 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =