This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @author arunprasathshankar | |
| * fields(variables) and methods are members of a class | |
| * 2 types of members | |
| * i) class members | |
| * ii) instance members(members associated with objects) — also called static members | |
| */ | |
| public class Circle { | |
| // class field : static is a must for class field(a.k.a static field) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Constructor Overloading | |
| class Rectangle { | |
| int l,b; | |
| double p,q; | |
| // Constructor 1 | |
| public Rectangle(int x,int y) { | |
| l = x; | |
| b = y; | |
| } | |
| public int first() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use of 'this' operator | |
| // class Rectangle2 shouldn't be declared public | |
| class Rectangle2 { | |
| int length,breadth; | |
| // 'this' is equivalent to self in python | |
| void show(int length,int breadth) { | |
| this.length = length; | |
| this.breadth = breadth; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Threads in java | |
| public class ThreadExample { | |
| public static void main(String[] args) { | |
| // note Thread below is class name for Thread(pre-defined in library) and not the class name of this program | |
| Thread th = new Thread(); | |
| System.out.println("Numbers are printing line by line after 5 seconds : "); | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Template Name: Blogger Redirection | |
| */ | |
| global $wpdb; | |
| $old_url = $_GET['q']; | |
| if ($old_url != "") { | |
| $permalink = explode("blogspot.com", $old_url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="<$BlogLanguageDirection$>"> | |
| <head> | |
| <script type="text/javascript"> | |
| <mainorarchivepage>window.location.href='http://www.yourdomain.com/'</mainorarchivepage> | |
| <blogger><itempage> | |
| window.location.href='http://www.yourdomain.com/blogger/?q=< $BlogItemPermalinkURL$>' | |
| </itempage></blogger> | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MatMux { | |
| public static void main(String[] args) { | |
| int array[][] = {{5,6,7},{3,4,5}}; | |
| int array1[][] = {{1,2},{3,4},{5,6}}; | |
| /* array2 is the resulting product matrix.. assign any random dimension.. here i have used 12 X 12 | |
| int array2[][] = new int[12][12]; | |
| int x = array.length; | |
| System.out.println("Array Length --> "+ array.length); | |
| System.out.println("Array1 Length -->"+ array1.length); | |
| System.out.println("Array Length -->"+ array2.length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| string reverse(string str); | |
| int main() { | |
| string s; | |
| cout << "Enter string to be reversed: " << endl; | |
| cin >> s; | |
| s = reverse(s); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <algorithm> | |
| using namespace std; | |
| int main() | |
| { | |
| string s; | |
| cout << "Enter string to be reversed: " << endl; | |
| cin >> s; | |
| reverse(s.begin(), s.end()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Dynamic Memory Allocation for objects | |
| #include <iostream> | |
| using namespace std; | |
| class Box { | |
| public: | |
| Box() { | |
| cout << "Constructor called!" << endl; | |
| } | |
| ~Box() { |
OlderNewer