Sort Items in a Java TreeSet

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

808 Views

First, create a TreeSet and add elements to it −TreeSet set = new TreeSet(); set.add("65"); set.add("45"); set.add("19"); set.add("27"); set.add("89"); set.add("57");Now, sort it in ascending order, which is the default −Iterator i = set.iterator(); while(i.hasNext()){ System.out.println(i.next()); }If you want to sort in descending order, then use the descendingIterator() method −Iterator j = set.descendingIterator(); while(j.hasNext()) { System.out.println(j.next()); }The following is an example to sort items in a TreeSet in ascending and descending order −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]){ TreeSet set ... Read More

Qualification vs Soft Skills: What Matters More Today?

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

227 Views

There is no denying in the fact that both qualification and soft skills are essential to move forward in our journey of life nowadays. Nobody can admit that only one out of these is sufficient and if someone, by chance feels so, he or she is mistaken.Importance of QualificationOur qualification plays a major role in case there is a job that requires candidates with M.B.A. or B.Tech. Now, how can someone, who does not have these degrees get a job there? A good qualification improves our chances of secure and settled life in the future.A good qualification is a must ... Read More

FTP mkdir Function in PHP

Samual Sam
Updated on 30-Jul-2019 22:30:24

109 Views

The ftp_mkdir() function is used to create a new directory on the FTP server.Syntaxftp_mkdir(con,dir);Parameterscon − The FTP connectiondir − The name of the directory to be createdReturnThe ftp_mkdir() function returns name of the directory on success, or FALSE on failureExampleThe following is an example that creates a new directory −

Get Absolute Filename Path from Relative Filename Path in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

266 Views

The method java.io.File.getAbsoluteFile() can be used to acquire the absolute filename path from a relative filename path in Java. This method requires no parameters. It returns the file that is defined by the path name.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] argv) throws Exception {       File file = new File("demo1.txt");       file = file.getAbsoluteFile();       System.out.println(file);    } }The output of the above program is as follows −Outputc:\JavaProgram\demo1.txtNow let us understand the above program.The method java.io.File.getAbsoluteFile() is used to ... Read More

Display Hour with SimpleDateFormat in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

462 Views

To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“H”) to display hour in a day.Format f = new SimpleDateFormat("H");Now, get the hour −String strHour = f.format(new Date());The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s"); ... Read More

8085 Program to Perform Bubble Sort in Descending Order

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

8K+ Views

In this program we will see how to sort a block of bytes in descending order using bubble sorting technique.Problem StatementWrite8085 Assembly language program to sort numbers in descending order where n number of numbers are stored in consecutive memory locations starting from 8041H and the value of n is available in memory location 8040H (Using BUBBLE sort).DiscussionIn this program we will arrange the numbers in bubble sorting technique. In this sorting technique, it will be executed in different pass. In each pass the smallest number is stored at the end of the list. Here we are taking the numbers ... Read More

Count Animation in Android TextView

Chandu yadav
Updated on 30-Jul-2019 22:30:24

1K+ Views

This example demonstrate about How to make count animation in Android TextView.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken text view to show count animation from 0 to 100.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.animation.ValueAnimator; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

ftp_nb_continue Function in PHP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

62 Views

The ftp_nb_continue() function continues to receive or send a file to the FTP server. That means the download continues.Syntaxftp_nb_continue(con);Parameterscon − The FTP connection.ReturnThe ftp_nb_continue() function returns any of the following values −FTP_FAILED − send/receive failedFTP_FINISHED − send/receive completedFTP_MOREDATA − send/receive in progressExampleThe following is an example. Here., “new.txt” is a local file, whereas server file is “server.txt” −

Display Minutes with SimpleDateFormat in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

173 Views

To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“m”) to display minutes.Format f = new SimpleDateFormat(‘”m”);Now, get the minutes in a string.String strMinute = f.format(new Date());The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s"); ... Read More

Get the First Ordered Element in Java TreeSet

Samual Sam
Updated on 30-Jul-2019 22:30:24

152 Views

To get the element ordered first i.e. the first element in TreeSet, use the first() method.Create a TreeSet and add elements to it −TreeSet set = new TreeSet(); set.add("65"); set.add("45"); set.add("19"); set.add("27"); set.add("89"); set.add("57");Now, get the first element −set.first()The following is an example to get the element ordered first in TreeSet −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { TreeSet set = new TreeSet(); set.add("65"); set.add("45"); set.add("19"); ... Read More

Advertisements