Skip to main content

Posts

Showing posts from January, 2020

Initialization blocks in Java

Hello friends, Welcome back. Today in this article, I'm going to explain you about the static block and initializer block. As the Java language is pure OOP language, whatever the code we write is only in classes. So whenever we use class to represent a real life entity, we use members in the class as the attributes or properties of that entity. To initialize those properties or members, we can use one of the way i.e. Constructor Setter method Inlinie Blocks I'm assuming that you are familiar with all methods. Here about first three methods, I'm just giving a short description. The first three methods are : we initialize member in constructor by using a parameterized constructor. Setter methods is a java standard which denotes that class's member should be private and it should have setter method so that the member can be initialized. Third method is inline i.e. when we declare a member or variable, at the same time, we set its value. In this article, we...

The final keyword in java

Hello friends, Welcome back 🙂. In this article, I'm going to give a short introduction to final keyword which would be helpful to know more about it. The final keyword in java has multiple uses. The main purpose of the final keyword is to add some restrictions on java elements (class, member and method). The restrictions have been described as below. Use of final keyword: 1. The final class : We can say the class is final when it declared as final. The restriction on final class is that the final class cannot be extended by any class. Rest of the behavior of the class remains same as any normal class. 2. The final method : The method declared using final keyword is to be said as final method. The restriction is that the final method cannot be overridden by derived class. This restriction applies to static method also. 3. The final member : The final member is the java class's member which is declared using final keyword. The restriction is that it can be initial...

Puttygen

Hello friends, Welcome back. Here in this short blog, I'm going to share my experience about `puttygen`, a linux tool which I've used for converting PEM file to PPK file. The purpose of this conversion was the PEM (Privacy Enhanced Mail) file which was generated by AWS for accessing SFTP, was not working in WinSCP client. So to resolve that, I've googled and I found that I need to convert PPK file to PEM file. To do so, I found a linux tool named puttygen. Here I'm just giving commands I've used, and the man page link for reference. Convert PPK to PEM: puttygen server.ppk -O private-openssh -o server.pem Convert PEM to PPK: puttygen server.pem -O private -o server.ppk The man page link :  https://linux.die.net/man/1/puttygen Hope this will help you. Thanks.

Static Keyword in Java

Hello friends, Welcome back 🙂 In this blog, I'm going to cover shortly about static keyword in Java. I'm assuming that you're familiar with the static keyword in java. Because I've written this blog in such a way that here only revision of the use of static keyword and the important points about static keyword which are rarely disclosed. So the first part will just be short description of static keyword, and second part will be the points about which, most of the new-bee or intermediate developers not familiar with. Please comment if anything is missing or not covered in this blog. 1. static member :     All the non-static variables/member objects of a class are scoped at object level i.e. we can access a class's variable by using instance of that class. But in Java, we can create a class level scoped variable by using static keyword. The static variables can be accessed by using class name i.e. ClassName.staticVar . To declare variable as static, we ju...