string array

Java String array examples (with Java 5 for loop syntax)

Java String array FAQ: Can you share some Java array examples, specifically some String array examples, as well as the Java 5 for loop syntax?

Sure. In this tutorial, we'll show how to declare, populate, and iterate through a String array, including the Java 5 for loop syntax. Because creating a String array is just like creating and using any other Java object array, these examples can also work as more generic object array examples.

Java “file open” and “file read” methods (examples) alvin February 1, 2010 - 7:53am

Java file reading FAQ: Can you share some off-the-shelf Java methods I can use to open and read files in Java?

Sure. Taken directly from my Java file utilities article (Java file utilities to open, read, write, and copy files), here is the source code for two Java methods that let you read a text file.

Java array sorting: How to sort a Java String array

Java array FAQ: Can you share an example of how to sort a Java String array?

Sure. The following source code shows how to sort an array of strings. In short, you can easily sort a string array with the Arrays class sort method, shown in bold below:

A Java instanceof array example

While working with various "Java instanceof" tests recently, my curiosity was piqued, and I thought I'd take a look at how the instanceof operator works when testing against a Java array.

Java: How to find the longest String in an array of Strings

Java String array FAQ: Can you share an example of how to determine the largest String in a Java String array?

Sure, in this tutorial I'll share the source code for a complete Java class with a method that demonstrates how to find the longest String in a Java string array.

Finding the longest string in a Java string array

Here's the source code that shows how to find the longest string in a Java String array:

Java: How to list the files in a directory

Java file directory list FAQ: How do I create a list of files in a directory using Java?

Here's a quick example of a Java class that demonstrates how to create a list of all files in a directory using just the Java File class. Specifically, this example shows how to list all the files in a directory, store those filenames in a String array, and then print the array.