blog RSS
Java - Generating random integers
While generating random int values in a specific range is fairly simple, it still requires that you understand the syntax and how to use the Java Random class. Let's take a quick look at some examples below which go over some options when generating a random number in Java depending on your Java version. Java 1.6 and older In older version of java it...
Java - "Could not find or load main class" Error
One of the most frequently encountered errors when learning Java programming is the "Could not find or load main class" error. Before we dive into understanding the cause of the error, it's first important to understand how to launch a program using the java command. The "Could not find or load main class" error can be caused by many things, let's start with the basics...
Python - Reading a file line-by-line into a list
A common question asked when programming with Python is How do I read every line of a file in Python and store each line as an element in a list? Below we will go over an example to show you how to read the file and append each line to the end of a list. Reading a small file into a...
Python - Call an External Command
Learning how to run an external command from inside python is fairly straightforward. Python supports several methods for calling an external command. Determining which method to use depends on the use case, view our examples below of calling an external command. Use subprocess.call() The recommended way to execute an external command in Python is by using the subprocess module. The example below uses the call() method to invoke...
Python - Convert int to string

One of the most common Python programming questions is, how do I convert strings to integers or integers to strings? Python int to string is a very common conversion. Check out our examples below to learn how to convert int to string using Python. If you need to convert bytes to string, have a look at our other Python post. Convert int to string using str() The str() method...