Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Tuesday, May 2, 2017
Android populate ListView from JSON data using Java Servlet HTTP Request
Android populate ListView from JSON data using Java Servlet HTTP Request
Solomons Perjury Ep 9 Eng Sub
Available link for download
Friday, February 24, 2017
Anonymous class in Java
Anonymous class in Java
Like other classes in java , anonymous is also a type of class but it doesnt have any name like other classes have their own name either defined by the user or pre-defined in the java by the java vendors. So anonymous class is defined as the class without name and it is defined by the user only.
An anonymous will be defined dynamically by the { } after the constructor of the current class. Like this,
new < constructor > { } ;
For every anonymous class a .class file will be generated like this,
< outer_class > $ < int_value > . class
< int_value > --> represents the number of times we are creating the anonymous class for the same outer class.
Anonymous class is always be the sub-class of the class/interface whose name is used while creating the anonymous class. For ex-
In the above program both the statement is going to create an anonymous class which is the sub-class of class prog. If you need any conformation for the point of sub-class then de-compile the .class generated for the anonymous class where you will find that
So from the above decompiled code we can confirm that anonymous class will act as the sub-class of the class through which it is created.
Important point regarding Anonymous class
So whenever there is the need of invoking multiple method we need to define the anonymous class method as the overridden method as because we cannot directly call two method with the object of the anonymous class. And we know that we can be able access single method at a time with the single object.
No need of wonder that how a class can exist without any name ?
Its not that it doesnt have any name but generated by the compiler at the run-time. So user cannot guess what compiler will generate the name for an anonymous class. Due of this reason we cannot be define any constructor for the anonymous class. And this is the answer to the answer to the question why we cannot create an constructor of an anonymous class?
An anonymous will be defined dynamically by the { } after the constructor of the current class. Like this,
new < constructor > { } ;
For every anonymous class a .class file will be generated like this,
< outer_class > $ < int_value > . class
< int_value > --> represents the number of times we are creating the anonymous class for the same outer class.
Anonymous class is always be the sub-class of the class/interface whose name is used while creating the anonymous class. For ex-
public class prog{
public static void main(String[] args) {
prog p = new prog(){};
prog p1 = new prog(){};
}
}In the above program both the statement is going to create an anonymous class which is the sub-class of class prog. If you need any conformation for the point of sub-class then de-compile the .class generated for the anonymous class where you will find that
class prog$1 extends prog{ } --> For p object
class prog$2 extends prog{ } ---> For p1 object .
So from the above decompiled code we can confirm that anonymous class will act as the sub-class of the class through which it is created.
Important point regarding Anonymous class
1. We cannot create any constructor or reference variable for the anonymous class as we need to know class name for creating a constructor.
2. As it the sub-class of its super type so we can store its object reference to its super class reference.
3. We cannot create multiple object for the an anonymous class as because user doesnt know the name of the anonymous class.
4. Whenever we try to create another object with the new operator the compiler will create another class extending its super type.
5. If we are storing the sub-class reference to its super type reference then we can be able to access the super class inherited members.
6. If we are not storing the anonymous class object reference to its reference then we can be able to access only one member. for ex-
public class prog{
public static void main(String[] args) {
new prog(){
void display() {
System.out.println("Anonymous class method");
}
}.display();
}
} We can see that we can be able to access display method of the anonymous class, if other methods are defined then we cannot access if we are not storing the object reference to its super type.
7. To access the other member defined in the anonymous class which is the overridden method of its super type so we need to write the method signature to the super type then only we can access the method defined in the anonymous class with the super type object reference storing the anonymous class object reference. For ex-
public class prog{
void show(){}
void display(){}
public static void main(String[] args) {
prog p = new pro(){
void display(){
System.out.println("Anonymous class method");
}
void show(){
System.out.println("By Object Reference");
}
};
p.show();
p.display();
}
}So whenever there is the need of invoking multiple method we need to define the anonymous class method as the overridden method as because we cannot directly call two method with the object of the anonymous class. And we know that we can be able access single method at a time with the single object.
Available link for download
Friday, February 10, 2017
Anonymous Array in Java
Anonymous Array in Java
If we are creating an array object then it will allocate memory and default value i.e zero is been set by the JVM in the allocated memory.
If we want to store the value at the time of declaring the array reference then we have the following statement,
< data_type > < var_name > [ ] = {< value1 > , < value2 >,< value3 >.....} ;
int value [ ] = { 10, 20, 30 } ; // Valid statement
int value [ ] = { 10, 20 ,30, , } ; // Invalid statement
int value [ ] ;
value = { 10, 20 ,30 } ; // Invalid statement it should be in one line .
Anonymous Array
Now if we have a requirement to assign the data at the time of creating the array object then we have the following statement and this is also known as Anonymous Array .
int value [ ] = new int[ ] { 10, 20, 30 } ;
We can also assign one reference to another reference variable. Like this,
int tmp [ ] ;
tmp = new int [ ] { 10,20,30 } ;
Note : We should not specify any size while creating the anonymous array .
Important points must be taken care while using array in java
1> We cannot assign one reference variable to another at the same level or who does not have any inheritance relation . For ex-
int arr [ ] = new byte [ 4 ] ; // Invalid cannot store byte into int type .
2> We cannot use + operator with the array reference for indicating the next member of the array because java do not deals with the address at the user level.
int arr [ ] = new int [ 4 ] ;
( arr + 1 ) ; // Invalid in Java
3> Cannot assign direct a string value to a array reference . For ex-
String arr [ ] = " Java " ;
The above statement is invalid and give compilation error saying " incompatible type " because compiler find the Java as a string type which is one of the class in java where as on the left side we have a String array. So it is " incompatible type " . Correct form is as following ,
String arr [ ] = { " Java " } ;
Now Java is a string is of array type.
If we want to store the value at the time of declaring the array reference then we have the following statement,
< data_type > < var_name > [ ] = {< value1 > , < value2 >,< value3 >.....} ;
int value [ ] = { 10, 20, 30 } ; // Valid statement
int value [ ] = { 10, 20 ,30, , } ; // Invalid statement
int value [ ] ;
value = { 10, 20 ,30 } ; // Invalid statement it should be in one line .
Anonymous Array
Now if we have a requirement to assign the data at the time of creating the array object then we have the following statement and this is also known as Anonymous Array .
int value [ ] = new int[ ] { 10, 20, 30 } ;
We can also assign one reference to another reference variable. Like this,
int tmp [ ] ;
tmp = new int [ ] { 10,20,30 } ;
Note : We should not specify any size while creating the anonymous array .
Important points must be taken care while using array in java
1> We cannot assign one reference variable to another at the same level or who does not have any inheritance relation . For ex-
int arr [ ] = new byte [ 4 ] ; // Invalid cannot store byte into int type .
2> We cannot use + operator with the array reference for indicating the next member of the array because java do not deals with the address at the user level.
int arr [ ] = new int [ 4 ] ;
( arr + 1 ) ; // Invalid in Java
3> Cannot assign direct a string value to a array reference . For ex-
String arr [ ] = " Java " ;
The above statement is invalid and give compilation error saying " incompatible type " because compiler find the Java as a string type which is one of the class in java where as on the left side we have a String array. So it is " incompatible type " . Correct form is as following ,
String arr [ ] = { " Java " } ;
Now Java is a string is of array type.
Available link for download
Saturday, January 28, 2017
Angular Java Script Indexes
Angular Java Script Indexes
- Model
- Scope
- Controller
- View
- Services
- Data Binding
- Directives
- Filters
- Validation
- Testing
Available link for download
Wednesday, November 11, 2015
Monday, November 2, 2015
Facebook PopUp Like Button with Timer On Blogger
Most bloggers use social networking sites like facebook to get more traffic to their blog. This is done either with facebook fan pages or groups depending on the number of fans. One of the ways you can increase your fans is to use a facebook popup like button or box that has a timer. This will be the first thing your readers will see as they visit your blog
.
The facebook like button unlike the facebook likebox that displays a box with the faces of the fans from the page, uses a button which your blog readers can click like your facebook page directly from your blog. You can also set the timer on this widget before it closes and your blog readers can also close it manually.
Also read: How to Add “Link To This Post” Widget Below Blogger Post
Static Facebook Popup Like Box Widget For Blogger
Auto Scrolling Recent Post Widget For Blogger
1. Go To Blogger dashboard
2. Select template, backup it up before proceeding. Select Edit HTML
3. Click inside the template, using ctrl+f search for </body> Copy the code below and Paste 'above' </body> either on the second or third </body> body tag depending on which might work on your blog.
Also Read: Most Commented Posts Widget For Blogger With Thumbnails
Recommended Post Slide Out Widget For Blogger
4. Before saving your blogger template, edit the code above by replacing USER-NAME with your facebook page username. You can also edit the timer, but it should not make your readers wait too long before viewing your blog content. Save the template.
.
The facebook like button unlike the facebook likebox that displays a box with the faces of the fans from the page, uses a button which your blog readers can click like your facebook page directly from your blog. You can also set the timer on this widget before it closes and your blog readers can also close it manually.
Also read: How to Add “Link To This Post” Widget Below Blogger Post
Static Facebook Popup Like Box Widget For Blogger
Auto Scrolling Recent Post Widget For Blogger
How to Add Facebook PopUp Like Button with Timer On Blogger
1. Go To Blogger dashboard
2. Select template, backup it up before proceeding. Select Edit HTML
3. Click inside the template, using ctrl+f search for </body> Copy the code below and Paste 'above' </body> either on the second or third </body> body tag depending on which might work on your blog.
<!-- informationtutorial15.blogspot.com Likebox Pro FBFan Code Start -->
<script type='text/javascript'>
//<![CDATA[
KNFBFansPRO='PAGE-NAME'
//]]>
</script>
<style>
#fblikepop{background-color:#fff;display:none;position:fixed;top:200px;_position:absolute; /* hack for IE 8*/width:450px;border:10px solid #900000;z-index:200;-moz-border-radius: 9px;-webkit-border-radius:
9px;margin:0pt;padding:0pt;color:#900000;text-align:left;font-family:arial,sans-serif;font-size:13px;
}
#fblikepop body{background:#FFF none repeat scroll 0%;line-height:1;margin:0pt;height:100%;
}
.fbflush{cursor:pointer;font-size:11px !important;color:#FFF !important;text-decoration:none !important;border:0 !important;
}
#fblikebg{display:none;position:fixed;_position:absolute; /* hack for IE 8*/height:100%;width:100%;top:0;left:0;background:#000000;z-index:100;
}
#fblikepop #closeable{float:right;margin:7px 15px 0 0;
}
#fblikepop h1{background:#900000 none repeat scroll 0 0;border-top:1px solid #900000;border-left:1px solid #900000;border-right:1px solid #900000;color:#FFFFFF !important;font-size:14px !important;font-
weight:normal !important;padding:5px !important;margin:0 !important;font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif !important;
}
#fblikepop #actionHolder{height:30px;overflow:hidden;}
#fblikepop #buttonArea{background:#FFFFFF;border-top:1px solid #9000000;padding:10px;minCCCCCCght:50px;
}
#fblikepop #buttonArea a{color:#999999 !important;text-decoration:none !important;border:0 !important;font-size:10px !important;
}
#fblikepop #buttonArea a:hover {color:#900000 !important;text-decoration:none !important;border:0 !important;
}
#fblikepop #popupMessage{font-size:12px !important;font-weight:normal !important;line-height:22px;padding:8px;background:#333 !important;
}
#fblikepop #counter-display{float:right;font-size:11px !important;font-weight:normal !important;margin:5px 0 0 0;text-align:right;line-height:16px;
}
</style>
<script type='text/javascript' src='https://sites.google.com/site/mmktricks/jquery.js'></script>
<script type='text/javascript' src='http://connect.facebook.net/en_US/all.js#xfbml=1'></script>
<script type='text/javascript' src='https://sites.google.com/site/mmktricks/fbpopup.js'></script>
<script language='javascript'>
//<![CDATA[
$(document).ready(function(){
$().KNFBFansPRO({
timeout: 20,
wait: 0,
url: 'http://www.facebook.com/USERNAME',
closeable: true });
});
//]]>
</script>
<div id='fbtpdiv'></div>
<!-- informationtutorial15.blogspot.com Likebox Pro FBFan Code End -->
Also Read: Most Commented Posts Widget For Blogger With Thumbnails
Recommended Post Slide Out Widget For Blogger
4. Before saving your blogger template, edit the code above by replacing USER-NAME with your facebook page username. You can also edit the timer, but it should not make your readers wait too long before viewing your blog content. Save the template.
Subscribe to:
Posts (Atom)

