I am trying to convert some java code to python. I have a problem with the following java lines : In java, i get those results : I think I understand the first line, but why is there a “(int)” here ? What is it supposed to do ? (I’m a beginner in java and in byte management, and I
Tag: integer
How can I convert arraylist to arraylist
My goal is to find on which specific index is String from ArrayList and add them to new ArrayList, So if house is [0] than i want to return new ArrayList with integer. At the begging I have ArrayList like this Input : And I want to get new ArrayList like this Output: Answer You can do it just by
Remove numbers from a list that begins with a specif digit
For example, i have this list How i remove only the numbers that begins with “6” Answer There are several ways how you can approach this task: using an Iterator; by utilizing so-called traditional for loop; with a help of Stream IPA; using method Collection.removeIf(). Note that attempt to address this problem using enhanced for loop (sometimes called “for-each” loop)
(Java) How do you check a string for two or more digit integers using .matches()?
The objective of this program is to return the atomic mass from a given formula (as a String), using a CSV file that contains elements and their atomic masses. My code for this particular problem is this: I have another method “fileReader” that takes the data from the mile and returns a map with the elements as the key and
Calculate percent [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question I was wondering how to calculate the percentage in a level system, let me explain better: The user has his experience and this represents the level
When having String and int as an output – how do I print string first?
This code doesn’t work, whenever I as an user input String data first and then int data, it just accepts input and doesn’t print out the data. If I change: position of these two code blocks, and enter int first and String as second value after then it happily prints first int number and then String. Please help out how
How do I check if my int array is empty, with the standard value being 0?
So I have come across an issue I do not seem to be able to fix. So lets say I have an int array and want to check whether the array still has space to add a certain element (from 0-∞) or has no space left, which would mean I would need to create a new array. The issue is
Casting a string to an integer and then to a double – how to retrieve up to four positions behind the decimal position in a correct way?
I am currently working on a simple BMI (Body Mass Index) calculator in Java, in a larger Java / Spring Boot application with Mojito Tests. My function uses height and weight as Input values to calculate the BMI. Through the arithmetic operations, the received Input values – Strings, casted to Integers – result in a number that represents the BMI;
Why do I need to assign -1 to an int for a random number guesser in Java
this is my first question here so I apologize if this has been answered before. I am working through beginner loops in university and am following along my textbook to program a number guesser. The code works, but what I don’t understand is why on line 17 I needed to create an int and give it a value of -1.
How to find max number and occurrences
So I’m learn java for the first time and can’t seem to figure how to set up a while loop properly . my assignment is Write a program that reads integers, finds the largest of them, and counts its occurrences. But I have 2 problems and some handicaps. I’m not allowed to use an array or list because we haven’t