0

java help

I don't know how to write code like this. The method returns those array elements in which the specified value does not occur. For example: I have a method like: static int[] arr(int[] a, int digits) then System.out.println(arr({5,245,4564,90}, 5)) and output is [90] .Such outputs because 90 doesn't have number 5, only 9 and 0 I am new in java and is for my class, I am not necessarily needing a ready-made solution but maybe algorithm or tips for solving this problem by myself. Thank you so much

28th Feb 2019, 8:52 PM
Kasia Herasymenko
Kasia Herasymenko - avatar
9 Respuestas
+ 4
Kasia Herasymenko You mean something like this: https://code.sololearn.com/c7wayVmAMiL4/?ref=app num = 5 a = {5,245,4564,90} outer for loop: loop through the array * d = a [i] * l = length of a [i] * boolean same = false inner for loop: * with d% 10 you get the last digit of a number (e.g. 45: 45% 10 = 5) * check if this digit = given num --> yes: same = true * cut the last digit of d --> d/10 Back to the outer for loop: * if same = false --> no digits of a [i] = given num --> add it to the list return list
1st Mar 2019, 12:59 AM
Denise Roßberg
Denise Roßberg - avatar
+ 3
Kasia Herasymenko Your welcome :)
2nd Mar 2019, 11:46 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Do you have the complete code of that project?
28th Feb 2019, 9:08 PM
lTheCrow
lTheCrow - avatar
28th Feb 2019, 9:45 PM
lTheCrow
lTheCrow - avatar
+ 1
What means that 5 in values?
28th Feb 2019, 10:02 PM
lTheCrow
lTheCrow - avatar
+ 1
Thank you so much for help:)
2nd Mar 2019, 11:34 PM
Kasia Herasymenko
Kasia Herasymenko - avatar
0
No, I dont know how to start :(
28th Feb 2019, 9:41 PM
Kasia Herasymenko
Kasia Herasymenko - avatar
0
no, I have a method like: static int[] arr(int[] a, int values) then System.out.println(arr({5,245,4564,90}, 5)) and output is [90] .Such outputs because 90 doesn't have number 5, only 9 and 0
28th Feb 2019, 9:57 PM
Kasia Herasymenko
Kasia Herasymenko - avatar
0
digits
28th Feb 2019, 10:05 PM
Kasia Herasymenko
Kasia Herasymenko - avatar