Refine search
Scanner sc = new Scanner(System.in); while (!sc.hasNext("exit")) { System.out.println( sc.hasNextInt() ? "(int) " + sc.nextInt() : sc.hasNextLong() ? "(long) " + sc.nextLong() : sc.hasNextDouble() ? "(double) " + sc.nextDouble() : sc.hasNextBoolean() ? "(boolean) " + sc.nextBoolean() : "(String) " + sc.next() ); }
public HeapHistogram(InputStream in, boolean jrockit) { time = new Date(); final Scanner sc = new Scanner(in, "UTF-8"); final List<ClassInfo> classInfos = scan(sc, jrockit); classes = new ArrayList<ClassInfo>(); permGenClasses = new ArrayList<ClassInfo>(); for (final ClassInfo classInfo : classInfos) { if (classInfo.isPermGen()) { permGenClasses.add(classInfo); totalPermGenBytes += classInfo.getBytes(); totalPermgenInstances += classInfo.getInstancesCount(); } else { classes.add(classInfo); totalHeapBytes += classInfo.getBytes(); totalHeapInstances += classInfo.getInstancesCount(); } if (!sourceDisplayed && classInfo.getSource() != null) { sourceDisplayed = true; } } if (!jrockit) { sc.next("Total"); final long totalInstances = sc.nextLong(); final long totalBytes = sc.nextLong(); assert totalInstances == totalPermgenInstances + totalHeapInstances; assert totalBytes == totalPermGenBytes + totalHeapBytes; } sort(); }
/** * CONSTRUCTOR - EXPLICIT Used by the * * @param sessionID * @param startTime * @param stopTime */ protected Session(final String sessionID, final String startTime, final String stopTime) { this.sessionIdTimeFormat = new SimpleDateFormat(SESSION_ID_DATE_FORMAT + SESSION_ID_DELIMITER + SESSION_ID_TIME_FORMAT, Locale.US); this.sessionIdTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Scanner s = new Scanner(startTime); this.startTime = s.nextLong(); s = new Scanner(stopTime); this.stopTime = s.nextLong(); this.sessionID = sessionID; if (this.stopTime == Long.MIN_VALUE) { this.stopTime = null; } }
/** * Used by deserealizer * * @param sessionID * @param startTime * @param stopTime */ protected Session(final String sessionID, final String startTime, final String stopTime) { this.sessionIdTimeFormat = new SimpleDateFormat(SESSION_ID_DATE_FORMAT + SESSION_ID_DELIMITER + SESSION_ID_TIME_FORMAT, Locale.US); this.sessionIdTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Scanner s = new Scanner(startTime); this.startTime = s.nextLong(); s = new Scanner(stopTime); this.stopTime = s.nextLong(); this.sessionID = sessionID; if (this.stopTime == Long.MIN_VALUE) { this.stopTime = null; } }
Scanner scn = new Scanner(System.in); int t = scn.nextInt(); for(int w = 0; w < t; w++){ BigInteger a = BigInteger.valueOf(scn.nextLong()); BigInteger b = BigInteger.valueOf(scn.nextLong()); BigInteger c = BigInteger.valueOf(scn.nextLong()); BigInteger d = BigInteger.valueOf(scn.nextLong()); BigInteger k = BigInteger.valueOf(scn.nextLong()); BigInteger g1,g2,num; ...
// completes in O(ln N) time. public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Factorial of which number: "); long num = sc.nextLong(); long zeros = 0; do { num /= 5; zeros += num; } while(num > 0); System.out.println("The number of trailing zero is " + zeros); }
Scanner reader = new Scanner(System.in); System.out.println("Enter a number: "); long limit = 5000L; long startTime = System.currentTimeMillis(); Long l = reader.nextLong(); if ((startTime + limit) < System.currentTimeMillis()) System.out.println("Sorry, your answer is too late"); else System.out.println("Your answer is on time");