Write a java program to sort names in an array?
HTML-код
- Опубликовано: 10 фев 2025
- This video explains java program to sort names in an array in java?
#learnwithkrishnasandeep #javacodinginterviewquestions #javaexamples #javaprograms #javatutorials #javaprogramming Join Telegram group : t.me/learnwith...
(For all updates on Java interview questions and java tutorials join the telegram group)
Search in Telegram with text Java Tutorials if you are unable to join telegram with above link
java program to sort array of strings,
java program to sort elements in an array,
java program to sort names in alphabetical order,
java program to sort names in array by index,
java program to sort names in array by value,
java program to sort names in array data,
java program to sort names in array descending order,
java program to sort names in array dictionary,
java program to sort names in array greater than,
java program to sort names in array hashmap,
java program to sort names in array having,
java program to sort names in array in java,
java program to sort names in array java,
java program to sort names in array list,
java program to sort names in array map,
java program to sort names in array names,
java program to sort names in array range,
java program to sort set of names stored in an array,
java program to sort the array,
www.keyword.io - Google longtail finder,
source code:
String name[]={"BANANA","APPLE","PINEAPPLE","MANGO","KIWI"};
int n = name.length; //array length=5
String tmp;
for(int i=0; i
amazing explanation sir
Ur teaching awsome.Subscribed to ur channel bro.
Explanation superb...
Nyc explanation ❤
Thanks 🙂
public class Program
{
static void Main(string[] args)
{
string[] str = {"Banana,Grapes,Apple" };
var splitstring = str.Select(x=> x.Split(",")).ToArray();
string[] result = splitstring[0].ToArray();
string temp = string.Empty;
for(int i =0;i< result.Length; i++)
{
for(int j =i +1;j< result.Length; j++)
{
if (result[i].CompareTo(result[j]) > 0)
{
temp = result[j];
result[j] = result[i];
result[i] = temp;
}
}
}
foreach(var x in result)
{
Console.WriteLine(x);
}
}
}
Why do you create two objects of scanner?
Same question
if you do not create a new object, it will take only 2 names in input, i.e. 1st i/p banana and second i/p grapes can be entered but can't enter 3rd i/p apple
If I give apple a as small and Banana B as capital and Grapes G as capital means the out put will be
Banana Grapes apple
Even if we gave the input in capital also it should come in alphabetical order so pls write a program for that
for(int i=0;i
@@sharonsam5687 hi. This is normal sorting program. If gave names ( Bala ,anbu,Ram ) like this also I want in alphabetically but Its not coming it's coming Bala,Ram,anbu.
Just do one thing. While sending the name to comapareTo method use toUpperCase() or toLowerCase() methods.
Why do you creat 2 objects of Scanner can't we just use 1 ?
Why do you creat 2 objects of Scanner can't we just use 1 ?
Why do you creat 2 objects of Scanner can't we just use 1 ?