blog RSS

The Programmer Blog is here to help you, the programmer. We do our best to provide useful resources that offer explanations to popular programming problems, across a variety of programming languages. If you would like to suggest a blog topic or have a question, please leave us a message.


Java, random

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...

Read more

CLASSPATH, Java

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...

Read more

python

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...

Read more

python, python external command, shell command, STDIN, STDOUT

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...

Read more

convert int to string, python, python int to string, repr(), str()

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...

Read more