Java program to sort the array elements using hard coded values not runtime values | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java program to sort the array elements using hard coded values not runtime values

What's the if () logic?

9th Mar 2019, 7:10 AM
Shrikar
Shrikar - avatar
11 Answers
+ 1
Your question is unclear, but I'm assuming you want to sort an array of numbers. There are many algorithms that can do this at varying efficiencies. Try looking up sorting algorithms, and see if you can find one that suits your needs.
9th Mar 2019, 7:19 AM
Austin
+ 1
I don't get it.. What not clear? Mention what you didn't get. If I could find why would I post? I want for hard coded not runtime.. Okay?
9th Mar 2019, 7:22 AM
Shrikar
Shrikar - avatar
+ 1
I couldn't find a code for hard coded.. If anyone knows pls send the code.
9th Mar 2019, 7:23 AM
Shrikar
Shrikar - avatar
+ 1
You want to sort an array that is hard coded and not input during runtime, right? It should be simpler doing it hard coded. Once you have your array, perform a bubble sort or insertion sort on it. Those are simple sorting algorithms that are decently efficient for small arrays
9th Mar 2019, 7:31 AM
Austin
+ 1
Well TQ but can't we solve it with if () condition? If so how?
9th Mar 2019, 7:43 AM
Shrikar
Shrikar - avatar
+ 1
Yeah but my doubt is in the if () loop condition taken is I>j but that doesn't satisfy.. We have to take the reverse condition then the action should be performed.. Like do you get what am saying.
9th Mar 2019, 8:01 AM
Shrikar
Shrikar - avatar
+ 1
And if you're quite good or pro in java would you mind giving me your FB id or anything cause I'm not able ask doubts here wholeheartedly..
9th Mar 2019, 8:04 AM
Shrikar
Shrikar - avatar
+ 1
Am already.. TQ for the suggestion. Well I got solve it for a while and be back of I have any queries.
9th Mar 2019, 8:11 AM
Shrikar
Shrikar - avatar
0
My whole doubt is in if loop and the swapping statements
9th Mar 2019, 8:02 AM
Shrikar
Shrikar - avatar
0
I mean I can't ask with typing everything.. Got to ask through audio
9th Mar 2019, 8:07 AM
Shrikar
Shrikar - avatar
0
That's fine but can't we do with for loop instead of for each? Y
9th Mar 2019, 9:37 AM
Shrikar
Shrikar - avatar