Friday, February 4, 2022

Python Installation on Windows

In this post we’ll see how to install Python 3 on Windows. There are two versions of Python- Python 2 and Python 3 so the first question when you start learning Python is which release to go for, Python 2 or Python 3?

Well if you are just starting to learn and there is no old Python project to worry about the compatibility then better to go with release 3 as the final Python 2.x version 2.7 release came out in mid-2010 and the 2.x branch will see no new major releases after that so Pyhton 2.x is legacy. On the other hand Python 3.x is under active development and has stable relases over the years. So, Python 3.x is the present and future of the language.

To get more information about the differences between Python 2 and Python 3, refer the wiki page-

Installing Python 3 on Windows

To download Python go to and select Downloads – Windows. That will take you to the page where you can download the Python installer for the current release.

installing python

Current stable release is Python 3.7.3 so click on the “Download Windows x86-64 executable installer” under the stable release to download the executable file (python-3.7.3-amd64.exe).

installing python windows

Once the installer is downloaded click on the downloaded installer to start the Python installation setup.

In the installation set up window-

  • Install launcher for all users
  • Check Add Python 3.x to PATH

Click "Install Now" link to start the Python installation.

Once the download is completed you can click on windows start button to look for the Python installation by going to applications under letter P.

Click on Python 3.x (64 bit) to open command line.

Alternatively you can go to Command Prompt and check for the installation by typing command python –version. It displays the installed version of the python.

You can enter the python command line by typing python and write your first hello word program there itself to display “Hello World”.

Python hello world

You can also use Python IDLE which is the graphical IDE for Python. In the menu you can see an option for IDLE.

Python IDLE

That's all for this topic Python Installation on Windows. If you have any doubt or any suggestions to make please drop a comment. Thanks!

>>>Return to Python Tutorial Page

Related Topics

  1. Functions in Python
  2. Python for Loop With Examples
  3. Inheritance in Python
  4. Name Mangling in Python
  5. Method Overriding in Python

You may also like-

  1. Constructor in Python - __init__() function
  2. Strings in Python With Method Examples
  3. Multiple Inheritance in Python
  4. Class And Object in Python
  5. How LinkedList Class Works Internally in Java
  6. Race Condition in Java Multi-Threading
  7. Spring MVC Exception Handling - @ExceptionHandler And @ControllerAdvice Example
  8. Introduction to Hadoop Framework

Thursday, February 3, 2022

strictfp in Java

strictfp is a keyword in Java that restricts floating-point calculations to ensure portability. As different platforms can handle different floating-point calculation precision and greater range of values than the Java specification requires, that may produce different output on different platforms. Using strictfp guarantees that results of floating-point calculations are identical on all platforms.

Usage of strictfp in Java

The strictfp modifier was introduced in Java with JVM 1.2 and is available for use on all currently updated Java Virtual Machines.

Floating-point calculations may vary on different platforms because of the precision used like the standard 32 bit precision, 64 bit precision, 80-bit double extended on x86 or x86-64 platforms. strictfp is used when a programmer might need every platform to have precisely the same floating-point behaviour, even on platforms that could handle greater precision.

strictfp modifier in Java can be used with-

strictfp can not be used with-

strictfp Java example

strictfp class StrictfpDemo {
  float f = 9.678f;
  strictfp public void displayValue(){

  public static void main(String[] args) {
    StrictfpDemo strictfpDemo = new StrictfpDemo();

It can be seen in the program how strictfp modifier is used with the class and the method.


That's all for this topic strictfp in Java. If you have any doubt or any suggestions to make please drop a comment. Thanks!

>>>Return to Java Basics Tutorial Page

Related Topics

  1. final Keyword in Java With Examples
  2. static Keyword in Java With Examples
  3. this Keyword in Java With Examples
  4. super Keyword in Java With Examples
  5. Core Java Basics Interview Questions And Answers

You may also like-

  1. Java Abstract Class and Abstract Method
  2. static Import in Java With Examples
  3. Java Automatic Numeric Type Promotion
  4. BigDecimal in Java With Examples
  5. Check Given Strings Anagram or Not Java Program
  6. TreeMap in Java With Examples
  7. Deadlock in Java Multi-Threading
  8. Java CountDownLatch With Examples

Wednesday, February 2, 2022

Java Stream - peek() With Examples

In Java Stream API there is a peek() method that returns a stream consisting of the elements of this stream, additionally performing the provided action on each element. Reading this description may remind of you another method map() in Java Stream API which also does the job of returning a stream consisting of the results of applying the given function to the elements of this stream. But, don’t get confused they are different methods with different syntaxes peek() method takes a Consumer as an argument where as map() takes a Function as an argument. Note that Consumer just consumes the value and returns no result whereas Function accepts one argument and produces a result.

Syntax of peek() method

Stream<T> peek(Consumer<? super T> action)

Method parameter is of type Consumer functional interface and method returns a new stream.

Some important points about peek() method.

  1. peek() is an intermediate operation.
  2. Intermediate operations are always lazy which means they won't start executing as and when encountered but only be executed when the steam pipeline starts to work. That means there must be a terminal operation at the end.
  3. As per Java documentation “This method exists mainly to support debugging, where you want to see the elements as they flow past a certain point in a pipeline”. So the main task of peek() method is to use it display elements after certain tasks just to check if results are as intended or not.

peek() method Java examples

1. In the example peek() method is used to display the returned stream elements after each operation.

import java.util.List;

public class PeekStream {

  public static void main(String[] args) {
    List<String> nameList = Stream.of("Amit", "Benjamin", "Rimmi", "Joshua", "Paige")
             .filter(e -> e.length() > 5)
             .peek(e -> System.out.println("Filtered value: " + e))
             .peek(e -> System.out.println("Mapped value: " + e))
    System.out.println("Names after stream execution- " + nameList);


Filtered value: Benjamin
Mapped value: BENJAMIN
Filtered value: Joshua
Mapped value: JOSHUA
Names after stream execution- [BENJAMIN, JOSHUA]

If there is no terminal operation, intermediate operations like peek() are not executed. You can remove the terminal operation collect() from the above example to check that.

public class PeekStream {

  public static void main(String[] args) {
    Stream.of("Amit", "Benjamin", "Rimmi", "Joshua", "Paige")
             .filter(e -> e.length() > 5)
             .peek(e -> System.out.println("Filtered value: " + e))
             .peek(e -> System.out.println("Mapped value: " + e));

No output on executing this code.

That's all for this topic Java Stream - peek() With Examples. If you have any doubt or any suggestions to make please drop a comment. Thanks!

>>>Return to Java Advanced Tutorial Page

Related Topics

  1. Java Stream - Collectors.teeing() With Examples
  2. Java Stream - allMatch() With Examples
  3. collect() Method And Collectors Class in Java Stream API
  4. Java Stream - findFirst() With Examples
  5. Spliterator in Java

You may also like-

  1. JVM Run-Time Data Areas - Java Memory Allocation
  2. Difference Between HashMap And ConcurrentHashMap in Java
  3. Compact Strings in Java
  4. Java Multithreading Interview Questions And Answers
  5. Java Program to Get Current Date and Time
  6. CanDeactivate Guard in Angular With Example
  7. Run Python Application in Docker Container
  8. Fair Scheduler in YARN