Problem: I need to calculate a CRC16 for hex codes like this one: 08010000016B40D8EA30010000000000000000000000000000000105021503010101425E0F01F10000601A014E000000000000000001 For this, I have a working solution in JavaScript. Due to new requirements, I have to translate this code into Java. Expected result: F…
Tag: java
Unable to retrieve data from database through JDBC query
I trying to make a connection to my DDBB in order to print all the columns from a table but I keep getting Null. I have checked the connection parameters and everything seems correct. I’m thinking that maybe there is something wrong with my query statement: Answer I managed to solve the problem by addin…
Returning a subset that has a duplicate
My question is how to detect the duplicate on one subset of array that does not exist in the other substring? For example Input: arr1 = 1,2,3 arr2 = 1,1 Output: Arr2 is not a subset of Arr1 So far everything else works fine and how I want it to but this duplicate one keeps returning that it is a
Get map dynamically based on key’s class type and avoid “raw use of parameterized class ‘Map'”
I have a cache class in which I used 2 HashMaps to keep the cache. I want to be able to choose the right map given key’s class type so that: if key is Long, then get value from map longKeyCache if key is String, then get value from map stringKeyCache. (assume user will only pass in Long or String
How do I insert an Item at a certain Index in a Linked List?
I am working on a project for my Data Structures class that asks me to write a class to implement a linked list of ints. Use an inner class for the Node. Include the methods below. Write a tester to enable you to test all of the methods with whatever data you want in any order. I have to create
Java Substring based on condtion
I’m pretty new to Java and I would like to know if there is an effective way of creating a substring based on conditions. Currently I am reading from a txt file and changing that txt file to a String format using BufferedReader. I am receiving several txt files but they all have the same format. The dat…
How to print failed assertions only without stack trace in soft assertAll() in Selenium?
Is there any way of printing just failed assertions without the entire stack trace when Selenium executes assertAll method? So, say this snippet has two assertions either returns true and false. So assertAll() method returns as below. What I want to see in the console log is like. Thank you in advance. Answer…
Pass calculated values by inherited classes to main class
So in my main function I got a class named Figure Circle and Rectangle extend class Figure. Square extends class Rectangle. Now I have to print the values from created objects. I think I am approaching this in wrong way. How can I pass the values to the print function that have been created by other classes? …
How to remove characters between two specific characters in a String?
How to remove characters between two specific characters in a String? Example: Original String: “Hello <>Remove this String<> how are you?” Modified String: “Hello <><> how are you?” Answer You can use regex like this: Output: Hello <><> how are you?
How to get indexes of char in the string
I want to find vowels positions in the string. How can I make shorter this code? I tried contains and indexOf method but couldn’t do it. Answer I assume you want to get m2rh5b7 from your input string Merhaba based on your code, then the below works fine, Or if you want just position of the vowels positi…