Skip to content

Instantly share code, notes, and snippets.

@derekmc
Created September 7, 2025 15:13
Show Gist options
  • Select an option

  • Save derekmc/fe430c7a9184cb63ea9f0cd97261bf13 to your computer and use it in GitHub Desktop.

Select an option

Save derekmc/fe430c7a9184cb63ea9f0cd97261bf13 to your computer and use it in GitHub Desktop.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
public class Test{
public static int minItem(ArrayList<Integer> l){
int y = Integer.MAX_VALUE;
for(int i=0; i<l.size(); ++i){
int x = l.get(i);
if(x < y) y = x;
}
return y;
}
public static void main(String[] args) throws IOException{
System.out.println("Hellworld!");
//File file1 = new File("test.txt");
//Scanner =
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
ArrayList<Integer> nums = new ArrayList<Integer>();
while(input.length() > 0){
int x = Integer.parseInt(input);
nums.add(x);
input = reader.readLine();
}
System.out.println("nums: " + nums);
System.out.println("min: " + minItem(nums));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment