Programming Leftovers

Java
-
Convert List to Array in Java
A list differs from an array, in the sense that it can grow or shrink in length. It can also have elements inserted within its length, and so increasing the length. It can also have its elements deleted. If the aim of the list is not to make it grow or shrink or have any special function, then the array should be used. And so, it would be necessary to convert a list to an array.
In Java, a list is not a class. It is an interface. An interface in Java is like an abstract class, but it is not meant to be subclassed. An interface is meant to have unrelated classes. The method declarations without body of the interface are defined in a class implemented from the interface. This should not be confused with instantiation. An object is instantiated from a class. A method is implemented from an abstract method, which may be a member of an interface, or an abstract class. With the interface, the “abstract” method declaration is not preceded by the reserved word, abstract. Note: a class created from an interface is said to have implemented the interface.
Among classes of list already implemented in the Java compiler, are the ArrayList, LinkedList and Vector. These three classes will be used to show how a list can be converted into an array in this article, beginning with the ArrayList.
-
Java Thread Sleep
A thread can be made to halt its execution for some time before it continues to operate. The thread is considered to sleep, in the period that it halts. But, what is a thread? A thread is a sub-program. It is possible to have more than one thread in one program, running concurrently. The main program itself is the main thread. A single threaded program is just the normal program. In Java, the normal program is the class that has the main() method. In a multi-threaded program, the main() method, can be considered as the main thread.
A thread can be created by sub-classing the Thread class. The thread can be made to sleep. This article explains how to make a thread sleep, beginning with a summary of how to create a new thread in Java. The Thread class does not need to be imported in order to have a thread in the program.
-
Recursion in Java
Recursion in Java is the calling of a method, by the method, from within the method. This action repeats itself until a condition is met. The method should be a method in a class, other than one in the main class. The main class is the class that has the main() method. The name of the Java file is that of the main class. A static method in the main class can still be made recursive, but that will not be addressed in this article. This article explains recursion in Java, with three good examples.
-
Java Thread Timer Usage
In Java, a timer is a class from which timer objects can be instantiated. The timer schedules task for execution in the near future. A task is like a method (function). Java has the class, TimerTask from which task objects can be instantiated. Different tasks are scheduled to operate (execute) at different times. This tutorial explains how to instantiate and use the timer object in Java, beginning with the instantiation of the TimerTask object and its nature.
-
Java instanceof Operator
The instanceof operator checks if its operand on the left is an object of its operand on the right. If yes, it returns true, otherwise it returns false, or issues an error message at compile time. The operand on the left should be an instantiated object of the operand on the right. The operand on the right is a type, e.g. a class.
-
2D Array in Java
In Java, a one-dimensional array is a consecutive set of values of the same type. The type of the values is the type of the array. A 1D array is an object from the Object superclass. A 1d array is a list. In this article, the list for the one-dimensional array is assumed to be displayed in a vertical column. A 1d array has the property length, which returns the number of elements in the array.
A two-dimensional array is a table. A table is a vertical list of horizontal lists. In Java, a two-dimensional array is an array of arrays. That is, a 2d array is a vertical array of horizontal arrays. That is, a 2D array in Java is a vertical list of horizontal lists. The 2D array has rows and columns. The length of the 2D array is the number of rows, which is the length property of the 1D column array. All the values in all the cells of the table are of the same type; this is said to be the type of the 2D array.
This article explains, what a 2D array in Java is, and how to create and access its elements. All code for this article takes place in the main() method.
-
&& and & Operators in Java
In Java, && is called the conditional-And operator. It is an example of a logical operator in Java. As another operator, & has two functions in Java. In one situation, it is called a logical-And operator. In the other situation, it is called the bitwise-AND operator. Each of these operators is a binary operator. This means that each has an operand on its left and on its right. The result of all that expression can be assigned to a variable. These operators work with primitive types, and so its class does not have to be imported by the programmer.
-
Absolute Value in Java
A number can be an int, a long, a float, or a double. The difference between an int and a long variable is that the long variable can hold a bigger value than an int variable. A long variable can also hold a number that an int would hold. Each of these number types can be negative or positive. For example, an int can be -5 or +5. When it is +5, the plus sign in front of it can be omitted.
So, a number can be negative or positive. Absolute value is simply the positive value of the pair. The positive value is still the number without a sign. Java has the math abs() method to return the absolute number. So, if the argument is -5, 5 will be returned. If the argument is +5 or 5, 5 will be returned. Java also has the absExact() method – see below.
These methods are all of the Math class. The Math class does not have to be imported by the programmer to be used. This article explains the use of the abs() and absExact() methods of the math class.
C++
-
Beginner C++ Projects
Students might find it challenging to get started with long and expert-level projects when learning a new language. Students used to derive help from books, online programming tutorials, and guides. However, these sources are not enough when you want to become an expert at a certain language. Hence, they try to search for projects which are less complicated, short, and simple to accomplish within the initial stage of practice. Within this guide, we will let you know about some C++ beginner projects along with their codes that are short and easy. Now, let’s start with Ubuntu 20.04 system.
-
Array as Parameter C++
Functions in C++ can accept different types of arguments when they are called. In the same manner, an array can also be passed as a parameter to a function in C++. To figure out whether passing an array as a parameter to a function in C++ is the same as passing any other type of argument to a function or not, you will have to give a read to this article.
-
Argc and Argv C++
While writing C++ programs, we all know that the “main()” function is considered very important since we cannot compile our program if the implementation of this function is missing. Just like all other functions in C++, the “main()” function is also capable of accepting arguments. However, the difference between passing arguments to the “main()” function from passing arguments to the other functions is that you have to pass the arguments through the command line in the former case. It is so because the “main()” function itself is the driver function which is why no other function is capable of calling it and passing arguments to it. In this article, we will be discussing the two parameters of the “main()” function, i.e., “argc” and “argv” in C++ in Ubuntu 20.04.
Misc.
-
2021.52 JDV Released – Rakudo Weekly News
Justin DeVuyst has announced the 2021.12 Rakudo Compiler Release, their first release and hopefully the first of many to come! Claudio Ramirez quickly provided Linux packages for this release. And JJ Merelo published updated Docker Containers. And Anton Oks published a new Rakudo Star Windows image. Good to see such cooperation! And good to see more and more coverage about the Raku Programming Language!
-
It’s Printable, It’s Programmable, It’s E. Coli | Hackaday
Well, whaddya know? It seems that E. coli, the bane of Romaine and spinach everywhere, has at least one practical use. Researchers at Harvard have created a kind of 3D-printable ink that is alive and made entirely of microbes produced by E. coli. Although this is not the first so-called living ink, it does hold the title of the first living ink that doesn’t need any additional polymers to provide structure.
-
Rust Dev Lang – how to view onboard html based documentation (man page) – The Rust Standard Library
-

- Login or register to post comments
Printer-friendly version- 1668 reads
PDF version
More in Tux Machines
- Highlights
- Front Page
- Latest Headlines
- Archive
- Recent comments
- All-Time Popular Stories
- Hot Topics
- New Members
digiKam 7.7.0 is released
After three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release.
|
Dilution and Misuse of the "Linux" Brand
|
Samsung, Red Hat to Work on Linux Drivers for Future Tech
The metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world.
Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility.
|
today's howtos
|








.svg_.png)
Content (where original) is available under CC-BY-SA, copyrighted by original author/s.

Recent comments
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago