Posts

Showing posts with the label Java

[Java] Multi-Dimension Arrays

Image
The arrays you have been using so far have only held one column of data. But you can set up an array to hold more than one column. These are called multi-dimensional arrays. As an example, think of a spreadsheet with rows and columns. If you have 6 rows and 5 columns then your spreadsheet can hold 30 numbers. It might look like this: A multi dimensional array is one that can hold all the values above. You set them up like this: int[ ][ ] aryNumbers = new int[ 6 ][ 5 ]; They are set up in the same way as a normal array, except you have two sets of square brackets. The first set of square brackets is for the rows and the second set of square brackets is for the columns. In the above line of code, we're telling Java to set up an array with 6 rows and 5 columns. To hold values in a multi-dimensional array you have to take care to track the rows and columns. Here's some code to fill the first rows of numbers from our spreadsheet image: aryNu...

[Programming Languages] 10 Programming Languages That Can Redefine IT

Image
Here are 10 latest programming languages which approach the art of software development from a fresh perspective, tackling a specific problem or a unique shortcoming of today's more popular languages. Many of them are capable of changing programming in subsequent years. . 1. Go Go, which is easy to program in, is a general-purpose programming language suitable for everything from application development to systems programming. It's more like C or C++. But like Java and C#, Go includes modern features such as garbage collection, runtime reflection, and support for concurrency. Go’s development is still in progress. 2. Dart JavaScript is used to add basic interactivity to Web pages, but doesn’t work well when the application has thousands of lines of code. That's why Google created Dart. It hopes this will change the way Web programming is done. Where JavaScript is a prototype-based language, objects in Dart are defined usi...

[Core Java] Serialization & Deserialization

Image
Objects can be flattened and inflated. Objects have state and behavior. Behaviour lies in the class but state lives in each individual object. So what happens when its time to save the state of an object? If you are writing a game, you would need a Save & Restore Game feature. Luckily there is a feature built in java which is to simply freeze-dry/ flatten / persist / dehydrate the object itself to save the state and reconstitute / inflate / restore / rehydrate to get it back.  You have lots of options for how to save the state of your Java Program, and what you will choose will probably depend on how you plan to use the saved state. Here are the options we will be looking at in this chapter.   If your data will be used by only the Java program that generated it:  Use serialization Write a file that holds flattened (serialized) objects. Then have your program read the serialized objects from the file and inflate them back into living, bre...