Java Guidence

Java Guidence

Share

This will help for java learners, i am interested to share my java Knowledge to others

20/03/2018

Java Program To Remove All Vowels From String Using replaceAll() Method
===========================================
public static void main(String[] args)
{
System.out.println("Enter the string...");
String inputString ="ABEFIJO";
String newInputString =
inputString.replaceAll("[AEIOUaeiou]", "");
System.out.println("The string without vowels...");
System.out.println(newInputString);
}

19/03/2018

How to create Immutable class in Java?
======================================
Immutable class means that once an object is created, we cannot change its content. In Java, all the wrapper classes (like String, Boolean, Byte, Short) and String class is immutable. We can create our own immutable class as well.
Following are the requirements:
• Class must be declared as final (So that child classes can’t be created)
• Data members in the class must be declared as final
• A parameterized constructor
• Getter method for all the variables in it
• No setters

19/03/2018

ExceptionHandling with MethodOverriding
=================================
1. If the super class method does not declare an exception
subclass overridden method cannot declare the checked
exception but it can declare unchecked exception.

2. If the super class method declares an exception
subclass overridden method can declare same, subclass
exception or no exception but cannot declare parent
exception.

03/12/2017

mvn command is not recognized as an internal or external command
===============================================================

Right click on My Computer >> Properties >> Advanced system settings >> System Properties window will get displayed Under Advanced >> Environment Variables

Click on New to set Environment Variables

Variable name: JAVA_HOME Variable value: C:\Program Files\Java\jdk1.8.0_121

Variable name: M2 Variable value: %M2_HOME%\bin

Variable name: M2_HOME Variable value: C:\Program Files\Apache Software Foundation\apache-maven-3.5.0

Variable name: Path Variable value: %M2_HOME%\bin

Now restart you command prompt and check again with “mvn –version” to verify the mvn is running, you may restart your system also.

03/12/2017

maven dependency for oracle (local path setting)
=====================================

com.oracle
ojdbc6
11.0
system
F:/Sotwares/SharedLib Jars/ojdbc6.jar

11/11/2017

The DECODE Function
=====================
The DECODE function in Oracle allows you to have IF-THEN-ELSE logic in your SQL statements.
The syntax is:
DECODE ( expression, search, result [, search, result]... [,default] )
ex : select decode(TRIM(to_char(SYSDATE,'Day')),'Monday','3','1') from dual
means if today is Monday then return 3 else 1

22/10/2017

Diff Statement Level trigger and Row Level Trigger
======================================
Let's say you have a trigger that will make sure all high school seniors graduate. That is, when a senior's grade is 12, and we increase it to 13, we want to set the grade to NULL.

For a statement level trigger, you'd say, after the increase-grade statement runs, check the whole table once to update any nows with grade 13 to NULL.

For a row-level trigger, you'd say, after every row that is updated, update the new row's grade to NULL if it is 13.

A statement-level trigger would look like this:

create trigger stmt_level_trigger
after update on Highschooler
begin
update Highschooler
set grade = NULL
where grade = 13;
end;
and a row-level trigger would look like this:

create trigger row_level_trigger
after update on Highschooler
for each row
when New.grade = 13
begin
update Highschooler
set grade = NULL
where New.ID = Highschooler.ID;
end;

ORA-12560: TNS:protocol adaptor error 22/10/2017

ORA-12560: TNS:protocol adaptor error
====================================

ORA-12560: TNS:protocol adaptor error I Google[d] for this error ORA-12560: TNS:protocol adaptor error but not able to find the actual reason and how to solve this error ? Can anyone tell me a perfect solution to solve login problem.

16/10/2017

For getting next element ID in jquery
======================================
$(this.nextElementSibling.id);
it will give next element of current object id

16/10/2017

ResourceBundleMessageSource using Annotation
===========
1. Bean Config

public MessageSource messageSource()
{
ResourceBundleMessageSource messageSource
= new ResourceBundleMessageSource();

messageSource.setBasenames("i18/users", "i18/errormsg");

messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}

2. get the object into your class

private MessageSource messageSource;
3. read the property
String name = messageSource .getMessage("errormsg.name", null, "Default", new Locale("de"));

16/10/2017

file size validation at front end using pure java script
============================================================


function getFileize(fileItem){
if(window.ActiveXObject){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var filepath = document.getElementById(fileItem).value;
var thefile = fso.getFile(filepath);
var sizeinbytes = thefile.size;
}else{
var sizeinbytes = document.getElementById(fileItem).files[0].size;
}
document.forms[0].fileSize.value=sizeinbytes;
//var fSExt = new Array('Bytes', 'KB', 'MB', 'GB');
//fSize = sizeinbytes; i=0;while(fSize>900){fSize/=1024;i++;}

//alert((Math.round(fSize*100)/100)+' '+fSExt[i]);
}

Want your school to be the top-listed School/college in Bangalore?

Click here to claim your Sponsored Listing.

Location

Category

Website

Address


Bangalore
560076