Skip to content

Instantly share code, notes, and snippets.

View NathanPB's full-sized avatar
🎯
Focusing

Nathan P. Bombana NathanPB

🎯
Focusing
  • Passo Fundo, Brazil
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@NathanPB
NathanPB / java-scanner-hell.md
Created December 19, 2021 02:31
Explanation of a confusion about the Java Scanners that usually guide beginners to a complete frustration

I've always seen a lot of confusion between (usually) beginners on the Java language about the use of Scanner. As someone who got a bit of knowledge on Java SE, I think I'm able to write a bit of content to help those who are struggling on that problem, just as I did in prior contacts.

As a use case, let's use the following code fragment:

Scanner s = new Scanner(System.in);

System.out.println("Enter your name:");
String name = s.next();
import java.util.*
fun main(args: Array<String>) {
val scanner = Scanner(System.`in`)
val operators = listOf('^', '*', '/', '+', '-', '>', '<', '=', '#', '.', '|')
val operands = "[a-zA-Z0-9]+".toRegex()
abstract class Expression
class OperandExpression(val left: Expression, val operator: Char, val right: Expression) : Expression() {
override fun toString() = "exp($left $operator $right)"
/**
* Created by nathanpb on 11/18/17.
*/
public enum ConsoleColors {
// Reset
RESET("\033[0m"), // Text Reset
// Regular Colors
BLACK("\033[0;30m"), // BLACK
RED("\033[0;31m"), // RED
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
import java.util.stream.Collectors;
public class ExercicioMap {
public static void main(String[] args) {
ArrayList<List<String>> csv = new ArrayList<>();
for(String line : readFile()){