public class StringBufferOperation{
public static void main(String[] args){
StringBuffer strBuf1 = new StringBuffer("Prashant");
System.out.println("strBuf " + strBuf1); //printing Prashant
System.out.println("strBuf " + strBuf1.capacity());//16(default capacity) + 8 characters of 'Prashant' ie.24
System.out.println("strBuf " + strBuf1.length());//showing length of string 'Prashant' ie. 8
System.out.println("strBuf " + strBuf1.charAt(5));//showing character at position 5 ie. 0-5 ie.'a' in string 'Prashant'
System.out.println("strBuf " + strBuf1.toString());//converts to a string representing the data in this string buffer.
strBuf1.delete(3,5);
System.out.println("strBuf " + strBuf1);//Printing Praant.
strBuf1.insert(2,'c');
System.out.println("strBuf " + strBuf1);// Printing Prashant as Prcashant
strBuf1.setCharAt(0,'r');
System.out.println("strBuf" +strBuf1);//It will Printing rrcshant.
//replace(int start, int end, String str)
// reverse()
//append(String str)
//setLength(int newLength)
}
}
Saturday, February 20, 2010
String In Java
StringBuffer class creates a dynamic character string.
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer strBuf1 = new StringBuffer("Prashant");
StringBuffer strBuf2 = new StringBuffer(100); //With capacity 100
StringBuffer strBuf3 = new StringBuffer(); //Default Capacity 16
System.out.println("strBuf1 : " + strBuf1);
System.out.println("strBuf2 capacity : " + strBuf2.capacity());
System.out.println("strBuf3 capacity : " + strBuf3.capacity());
}
}
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer strBuf1 = new StringBuffer("Prashant");
StringBuffer strBuf2 = new StringBuffer(100); //With capacity 100
StringBuffer strBuf3 = new StringBuffer(); //Default Capacity 16
System.out.println("strBuf1 : " + strBuf1);
System.out.println("strBuf2 capacity : " + strBuf2.capacity());
System.out.println("strBuf3 capacity : " + strBuf3.capacity());
}
}
Tuesday, February 16, 2010
Jquery Basics
Lesson from link-->http://www.catswhocode.com/blog/learning-jquery-the-basics
1>$(document).ready(function() {});
in jquery is same as
window.onLoad() in javascript
2>$('.comments')
if you use 'p' instead '.coments' then jquery will find all paragraphs.
Same thing for CSS just use '#' instead '.'
3>$('.comments').addClass('stripe');
Stripe would add gray background to comments.
Another example-->$('.comments:odd').addClass('stripe');
4>$('.comments').mouseOver(function() {
$('this').addClass('hover');
});
Remove class on mouseover.
Another example like this-->
$('comments').mouseOut(function() {
$('this').removeClass('hover');
});
1>$(document).ready(function() {});
in jquery is same as
window.onLoad() in javascript
2>$('.comments')
if you use 'p' instead '.coments' then jquery will find all paragraphs.
Same thing for CSS just use '#' instead '.'
3>$('.comments').addClass('stripe');
Stripe would add gray background to comments.
Another example-->$('.comments:odd').addClass('stripe');
4>$('.comments').mouseOver(function() {
$('this').addClass('hover');
});
Remove class on mouseover.
Another example like this-->
$('comments').mouseOut(function() {
$('this').removeClass('hover');
});
Sunday, February 14, 2010
Picture Paste
Frustrated by not being able to paste pictures into Gmail or Google docs?
Simply Go->
http://www.picturepaste.com/
Simply Go->
http://www.picturepaste.com/
Draggable Elements
Lovely Draggable Elements[Free To Use].
http://www.dhtmlgoodies.com/index.html?page=dragDrop
http://www.dhtmlgoodies.com/index.html?page=dragDrop
Saturday, February 13, 2010
Saturday, February 6, 2010
Jquery Menu With Download
Best Jquery Menus [Its Free To Use]-->
http://www.1stwebdesigner.com/resources/38-jquery-and-css-drop-down-multi-level-menu-solutions/
http://www.1stwebdesigner.com/resources/38-jquery-and-css-drop-down-multi-level-menu-solutions/
Open Blocked Sites.

To Access Blocked Sites In Your Office-->
http://www.hongkiat.com/blog/how-to-access-blocked-web-sites/
Scroll Offset
To make scroll onload at bottom i.e.(offset plus)
document.element.scrollIntoView(true);
And
To Make scroll on top i.e.(offset minus)
document.element..scrollIntoView(false);
document.element.scrollIntoView(true);
And
To Make scroll on top i.e.(offset minus)
document.element..scrollIntoView(false);
Browser Detect
The same code to detect broser in jquery can be seen on-->
http://javascriptly.com/2008/09/javascript-to-detect-google-chrome/
http://javascriptly.
JQUERY Browser DETECT
var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
var is_mozilla = /mozilla/.test( navigator.userAgent.toLowerCase() ) && !/(compatible|webkit)/.test( navigator.userAgent.toLowerCase() );
var is_safari=/webkit/.test( navigator.userAgent.toLowerCase() ) && !/chrome/.test( navigator.userAgent.toLowerCase() );
var is_msie=/msie/.test( navigator.userAgent.toLowerCase() ) && !/opera/.test( navigator.userAgent.toLowerCase() );
var userAgent = navigator.userAgent.toLowerCase();
// Figure out what browser is being used
jQuery.browser = {
version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/ ) || [])[1],
chrome: /chrome/.test( userAgent ),
safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};
var is_mozilla = /mozilla/.test( navigator.userAgent.
var is_safari=/webkit/.test( navigator.userAgent.
var is_msie=/msie/.test( navigator.userAgent.
var userAgent = navigator.userAgent.
// Figure out what browser is being used
jQuery.browser = {
version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/ ) || [])[1],
chrome: /chrome/.test( userAgent ),
safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};
Subscribe to:
Comments (Atom)

