[Solved] How to call value of object inside object?

I’m not going to fix your code for you. Doing that is part of your homework. However, here are a couple of hints to start you in the right direction. Hint: Look carefully at how your Reservation constructor (tries to) initialize the object’s fields. See the problem? Hint 2: The problem that tripped you up … Read more

[Solved] Java Quoting string variables

You start by taking the string. ansible-playbook delete.yml –extra-vars “host=5.955.595 user=root pass=anotherpw vm=myVm” Then you escape all special characters. In this case, that’s just the 2 double-quotes. ansible-playbook delete.yml –extra-vars \”host=5.955.595 user=root pass=anotherpw vm=myVm\” Then you surround that with double-quotes, to make it a Java string literal. “ansible-playbook delete.yml –extra-vars \”host=5.955.595 user=root pass=anotherpw vm=myVm\”” Then … Read more

[Solved] How to put positive numbers to Scanner and then stop it by entering negative one?

Hope this helps. Code can be improved with exceptions checks. This one is just to get started with. package com.samples; import java.util.Scanner; public class ScannerSample { public static void main(String [] args) { Scanner scanner = new Scanner(System.in); int [] mas = new int[50]; int inputInt = scanner.nextInt(); mas[0] = inputInt; int count = 1; … Read more

[Solved] read dates line by line from text file and store them in a dictionary java [duplicate]

You can try the following function. public static void parseFile() throws IOException, ParseException { BufferedReader bufferedReader = new BufferedReader(new FileReader(new File(“inputFileName.txt”))); Map<Integer, Date> integerDateMap = new HashMap<>(); // Map to put data SimpleDateFormat sdfmt2= new SimpleDateFormat(“dd/MM/yyyy”); // date format String line = null; line = bufferedReader.readLine(); // neglect first line while((line = bufferedReader.readLine())!= null){ String[] … Read more

[Solved] How to convert large numbers in a text file (strings) into ints and add them

Maybe this code can help. public static void main(String[] args) throws Exception { // write your code here Scanner scanner = new Scanner(new File(“C:\\directory\\test.txt”)); List<BigInteger> bigIntegers = new ArrayList<>(); while (scanner.hasNext()) { bigIntegers.add(new BigInteger(scanner.next())); } BigInteger total = new BigInteger(“0”); for(BigInteger bigInt: bigIntegers) { total = total.add(bigInt); } System.out.println(total); } 3 solved How to convert … Read more

[Solved] Best way to test a method that works with streams [closed]

Unittests in general test public observable behavior in your case it is the interaction with the two streams. create mocks for the two steams (usually I’d suggest to use a mocking framework but there are some simple implementations in the standard lib quite suitable for this purpose…) Configure the inputStream to return data in false … Read more