How can you loop backward? - Cracking the Java Coding Interview

  Рет қаралды 28,733

Java

Java

Ай бұрын

Cracking the #Java #Coding #Interview - Question 152: How can you loop backward?
Watch all the questions here: • Cracking the Java Codi...

Пікірлер: 24
@siriusmain1763
@siriusmain1763 Ай бұрын
Youngest Java enthusiast
@loic.bertrand
@loic.bertrand Ай бұрын
In Java 21 you can also use the reversed() method on SequencedCollection and SequencedMap which returns a reversed view of the collection.
@_PranayW
@_PranayW Ай бұрын
Tell me how can I learn Java? Any websites or video?
@heeteshdoorbiz
@heeteshdoorbiz Ай бұрын
​@_PranayW Choose a FreeCodeCamp video. Write code along the way when watching video. You don't need to understand everything it will slowly make sense later as you keep coding.
@Speiger
@Speiger Ай бұрын
Technically all set/Maps can be iterated backwards too because they have a forwards iterating order that is consistent meaning you can easily implement a backwards implementation.
@shashankmutgi9330
@shashankmutgi9330 24 күн бұрын
Is that Jose Paumard? This guy's course on completablefuture landed me my current job. Thanks Jose!
@csm2526
@csm2526 Ай бұрын
Why predefined methodscwhile you can rotate using for loop starting from nth element by reducing 1 each until the index>=0. Also using do while starting ftom nth element by reducing 1 each until the index>=0
@sergios6794
@sergios6794 Ай бұрын
That traditional forloop is not recommended if you only have the object through the interface List (you don't know the implementation), because depending on the implementation, the get(int index) method can have a really bad performance for executing in a loop, like a LinkedList.
@csm2526
@csm2526 Ай бұрын
@@sergios6794 why get method Sir just call the toArray. Mylist[]=list.toArray(); now for(int i=Mylist.length;i>=0;i--)s.o.p(Mylist[i]); simply reverse the list.
@csm2526
@csm2526 Ай бұрын
​@@sergios6794I hope yiu are convinced now
@jay_sensz
@jay_sensz Ай бұрын
@@sergios6794 That may be technically true, but in practice LinkedList is essentially obsolete because ArrayList is more performant (and less memory intense) under most circumstances.
@sergios6794
@sergios6794 Ай бұрын
@@jay_sensz I did an example, linkedlists and arraylists are not the only implementations of list. External libraries can provide their own implementation, that's because i said "when you only have the interface object"
@abhishekghosh2293
@abhishekghosh2293 Ай бұрын
If we have an ArrayDeque that has some elements, then we can use - descending iterator. something like this. It's super useful. Deque stack = new ArrayDeque(); Iterator itr = stack.descendingItrerator(); while(itr.hasNext()) { // Do some processing someList.add(itr.next()); }
@hamza201183
@hamza201183 Ай бұрын
Or a for-loop with i-- :p
@JuanGarcia-zy8yw
@JuanGarcia-zy8yw Ай бұрын
No sir … forget about that imperative style
@hamza201183
@hamza201183 Ай бұрын
@@JuanGarcia-zy8yw It just answers the question too. But aren't the suggested answers in the video also imperative?
@31redorange08
@31redorange08 Ай бұрын
Have fun doing this with a LinkedList.
@jonsmith7718
@jonsmith7718 Ай бұрын
is that authentic java bean coffee?
@maxmustermann19203
@maxmustermann19203 Ай бұрын
java is hard
@andrewcgs
@andrewcgs Ай бұрын
Java coding tip #1: don't
@happyday2912
@happyday2912 Ай бұрын
is java dying?
@theirongiant74
@theirongiant74 Ай бұрын
Preach it
Java 21 API New Features #RoadTo21
16:48
Java
Рет қаралды 37 М.
Can you beat this impossible game?
00:13
LOL
Рет қаралды 65 МЛН
ПООСТЕРЕГИСЬ🙊🙊🙊
00:39
Chapitosiki
Рет қаралды 60 МЛН
The standard library now has all you need for advanced routing in Go.
13:52
Stream Gatherers | Java 22 New Feature
16:57
Code Wiz
Рет қаралды 186
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 742 М.
New Java Version 22 - The 3 Best New Features You'll ACTUALLY Use
13:15
Coding with John
Рет қаралды 89 М.
What is JAVA With Full Information? - [Hindi] - Quick Support
9:42
Quick Support
Рет қаралды 1,4 МЛН
Module Imports in Java 23 - Inside Java Newscast #69
5:18
Самый топовый ПК без RGB подсветки
1:00
CompShop Shorts
Рет қаралды 55 М.
ВСЕ МОИ ТЕЛЕФОНЫ
14:31
DimaViper Live
Рет қаралды 44 М.
Где раздвижные смартфоны ?
0:49
Не шарю!
Рет қаралды 702 М.
Main filter..
0:15
CikoYt
Рет қаралды 2 МЛН