Powered by Blogger.
Showing posts with label CoreJava. Show all posts
Showing posts with label CoreJava. Show all posts

strip only the numbers from any formatted string of phone number

>> Thursday, April 23, 2020

This is a method which returns a string contains numbers init.The phone numbers may contain in differnt formats Ex: (123) 456-7890
                                 123-456-7890
so we can read these type of characters and returns only the numbers using java method isDigit from Character class.

Read more..

Display first fetter of a word with Capital letter in a given Sentence or String

>> Friday, February 28, 2020

The below code will display every first letter of a word in the sentence will display as a capital letter or in Camel Case using java program.
CamelCase Words in the Sentence

Read more..

Java - Unable to Split a String on Caret (^) symbol as a delimiter

>> Saturday, July 29, 2017

In Java Regular Expressions , Caret ( ^ ) is a Special character. Here it means "it should match the beginning" of an input.
Split method using the Caret symbol on String

Read more..

Java Program to find Perimeter of a Circle

>> Saturday, January 30, 2016

The Mathematical equation to find Perimeter or Circumference of a Circle is C=2πr. We can write hte above equation in our program as 2*Math.PI*r
In this tutorial we will learn how to calculate Perimeter(Circumference) of a Circle using java program. To write this program we are using predefined classes like Math, Scanner or BufferedReader. BufferedReader used to read the value of radius at runtime or from console.
Perimeter Of a Circle

Read more..

Java Program to Calculate Area of a Circle

The Mathematical formula to find Area of a Circle is : A= πr2 or we can write it as given below.
area = pi * radius * radius
So, to find Area of a circle we need the values of 'pi' and radius. In java we have predefined Mathematical value for pi is defined in java.lang.Math.PI = 3.141592653589793. PI is a static final value.
In our program we need to read radius value from the console by using BufferedReader or Console classes.
Calculate Area of a Circle using Java

Read more..

Can I write a Java program without main method ?

>> Thursday, August 13, 2015

Yes, We can write a java program without main method by using static block, only in java version 6. But not possible in later versions like java 7 or 8.
Before going to discuss "How to write a java program without main method", let's get an idea about the programs, which are running without main method.
Java Program without main method_JavabynataraJ

Read more..

Default value of primitive data types in Java

>> Saturday, August 8, 2015

In Real life to store any type of element/material, it should have suitable containers. Lets take water bottle can hold little water, like wise egg tray can hold eggs e.t.c. So to hold any object, there should have their suitable containers. In the same way, any form of the data can be stored by using the primitive data types based on their properties or attributes of the objects.
Default values of primitive data types_javabynataraj

Read more..

Best practice to find Duplicate Character from a String in java

>> Sunday, June 28, 2015

This program could be the best way to find the number of duplicate characters from the given String. Here we are using Map and Set from java.util.Collections package. In the below program we are using Set to collect different characters from the given String. One boolean variable and one method named as findDuplicateChar(String myString) to find the duplicates. Also some known methods like toCharArray() to convert String to character array and for-each loop to iterate Set and Array. Better you can go through the given program to find duplicate characters from the given String.
Find duplicate characters program_JavabynataraJ

Read more..

What are Generics in Java

>> Saturday, March 28, 2015

In common term Generic means a common type of things or relating to a class or group of things not specific.

In Java Generics are introduced in 2004 within Java 5.0 features along with Enum, autoboxing and varargs , to provide compile time type-safety.Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types, respectively.
What is type-safety?
It is just a check by compiler that correct Type(datatype) is used in correct place and there should not be any ClassCastException.

Read more..

Static Import in Java with an Example

>> Thursday, December 25, 2014

What is Static Import:
Static Import is a feature added in Java 1.5(released in Sep 30 2004 almost 10 years back!) along with Var-args,Auto-Boxing and Auto-Unboxing, Generics, Enhanced for-loop,Enums,Scanner Class and Annotations. Using this Static Import feature we can import static members of a class and as well we can access all non-private static members without using class name from other classes.

Read more..

Core Java notes by Mr.Ratan from Durgasoft

>> Monday, December 1, 2014

Mr. Ratan is a faculty for Core Java from Durga Software Solutions. He covers all the topics in core java including AWT,Swings. He will give training for OCJP exam preparation tips in the Core Java class. This will be useful to write exam without preparing dumps. Mr.Ratan will explain the classes in slow manner to understand easily for beginners. You can watch a demo class of Mr.Ratan.
Core Java notes by Ratan_JavabynataraJ

Read more..

Different type of Vararg rules in Java

>> Tuesday, November 25, 2014

While writing methods using variable arguments(var-args), we may confuse in different scenarios like where to put var-args in the parameters and how to place different type of arguments.Here we have given some rules with scenarios to understand easily. This will help you in the SCJP examination and as well, java interviews for freshers and experienced guys.
varargs rules JavabynataraJ

Read more..

OCJP and Core Java class notes by RamiReddy sir

>> Monday, November 17, 2014

RamiReddy sir is a Oracle Certified Professional and OCJP(SCJP) trainer. He is a good faculty in java for the beginners. He gives more example programs on core java to understand core java in depth.Before going to the Class notes he has given some interview tips and how to improve communication skills with real time java interview questions. His java class will start with basics and anyone can understand easily.
SCJP and Core Java notes by RamiReddy sir_JavabynataraJ

Read more..

Variable argument or varargs in Java

>> Thursday, November 6, 2014

The full form of var-args is variable length arguments and this one of the java 1.5 features.Also we have some important autoboxing, generics,for-each loop, static imports and some more. This feature is introduced to solve the problem in defining methods for taking '0' to 'n' number of arguments. These arguments should be of same types.  So, by using this feature we no need to define multiple overloaded methods for executing same logic with different no.of.values of same type.
java var-args explanation_JavabynataraJ

Read more..

Program to Convert Decimal to Octal,Hexa and Binary values

>> Saturday, October 18, 2014

Binary, Hexa and Octal are the number formats to use in different mathematical calculations. In our real life we use numbers with decimals. It may be integer value or float value both are called as decimals. Let us know the number format examples given below:
Decimal format : A representation of a real number using the base ten and decimal notation.
program to convert decimal to octa-hexa-binary_JavabynataraJ

Read more..

Java - Synchronized block and method in detail

>> Saturday, September 20, 2014

Java is a multi-threaded programming language. So in every program multiple threads run in parallel to complete the program execution.At this point of time the results may differ or order of execution will change. To prevent the inaccuracy or inconsistency of data results, Java has provided 'synchronized' keyword to implement in 'synchronized block' and 'synchronized method'. The synchronized object won't allow two threads to access at the same time. So that one thread can't be reading while another updates it.The Second Thread should wait until the first is done.
Synchronized keyword in Java_JavabynataraJ

Read more..

java.util.HashMap in detail with a program

>> Friday, September 12, 2014

HashMap is a class from java.util package and extends AbstractMap, implements Map,Cloneable and Serializable interfaces. HashMap contains Key,Value parameters we can denote it as HashMap<Key,Value> or HashMap<k,v>.Map allows only one null key and many null values and all the methods in HashMap are not synchronized. HashMap is an unordered collection , means the keys and values will not maintain insertion order.
An instance of HashMap has two parameters that affect its performance: initial capacity and load factor.
Let us know the terminology used in HashMap.

Read more..

program to read/find emails from the given text file

>> Sunday, September 7, 2014

Today morning i need to collect some emails of java guys from the java fourms or websites. So i started copying emails in this page by slecting the email and copying using Ctrl+C, i have done 20 emails copied. Then i lose my patience to copy. Immediately i got an idea, why can't i write a program to read all the emails from the page. Then i copied all the text from the page and pasted in a text file named as emails.txt. Now the java program came in to the picture and we should use java.io package to write or read file operations. In addition i am taking java.util.HashSet and java.util.regex packages to start our program. Here we are reading a text file containing emails with text and writing into another text file this is called deserialization and serialization.
find emails from the given text file_JavabynataraJ

Read more..

4 Ways to Reverse an Array in Java

>> Wednesday, August 20, 2014

Explain 'different ways to reverse an array' is one of the famous java interview questions. Using an array in programming is common with primitive types like e.g. int, long, double and String arrays to perform some operations. But to understand quickly we are using integer array with numbers to reverse. Actually we should know different types of arrays and how to iterate them. The basic programs on adding two matrices and multiplication of matrices is important .
four ways to reverse an array in java_JavabynataraJ

Read more..

matrix multiplication using arrays in java

>> Tuesday, August 12, 2014

Matrix Multiplication using arrays is very basic practice to learn for beginners to understand the concept of multidimensional matrix.Before to this you can check different types of arrays in java and get to know how to declare and define the arrays and also get practice with adding two matrices. Let me explain the matrix multiplication to understand in mathematical way and then we do the programmatically in java. Here we have some rules to follow for matrix multiplication.
matrix multiplication using arrays in java_JavabynataraJ
 Principles to follow matrix multiplication:

Read more..

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.