Posts

creating pandas series

import pandas as pd s=pd.Series([ 1 , 2 , 3 , 4 , 5 , 6 , 7 ]) print (s) s=pd.Series([ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] , name = "marks" ) print (s) #here we are changing index style from 012 to aa bb cc s=pd.Series([ 1 , 2 , 3 , 4 ] , index =[ 'aa' , 'bb' , 'cc' , 'dd' ]) print (s) #series created by dictionary , it is possible with pandas but not in numpy s=pd.Series({ 11 : "one" , 2 : "two" , 3 : "three" , 4 : "four" }) print (s) #we used scaler quantity s=pd.Series( 2.12 ) print (s) #here we are changing index style from 012 to aa bb cc. we used scaler quantity s=pd.Series( 2.12 , index =[ 'aa' , 'bb' , 'cc' , 'dd' ]) print (s)

CREATING OBJECT USING REFLECTION

Image
 import java.lang.reflect.*; import java.util.*; class A { public A() { System.out.println("A class instance created"); } static { System.out.println("static of A"); } } class B { public B() { System.out.println("B class instance created"); } static { System.out.println("static of B"); } } class Blog { public static void main(String ar[])throws Exception { Scanner scan=new Scanner(System.in); String str=scan.nextLine(); Class cc=Class.forName(str); cc.newInstance(); } }

HELLO WORLD PROGRAM IN JAVA

Image
 package programmer; //YOUTUBE CHANNEL:PROGRAMMER BUDDIEs. //TODAYS TOPIC:HELLO WORLD IN JAVA. class Programmer { public static void main(String ar[]) { System.out.println("Hello World"); System.out.println("Hii"); } }

ACCESSING FUNCTION OF ONE CLASS FROM OTHER CLASS IN JAVA

Image
 public class A {     int x=22;     public static void show(int xy)     {     System.out.println("show with one parameter  :"+xy);     }     public void show()     {     System.out.println("show with zero parameter ");     } } class Programmer { public static void main(String ar[]) { A obj=new A(); obj.show(); A.show(5); System.out.println(obj.x); } }

getMethods and getDeclaredMethods in java

getMethods() and getDeclaredMethods() in java Program : import java.lang.reflect.*; class A { public void show_Of_A() { } public void display_Of_A() { } } class B { public void show_Of_B() { } public void display_Of_B() { } } class Test { public static void main(String args[]) throws Exception { Class cc = Class.forName("A"); Method meth[] = cc.getMethods(); for(Method m:meth) { System.out.println(m); } } } Output :    public void A.show_Of_A() public void A.display_Of_A() public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException public final void java.lang.Object.wait() throws java.lang.InterruptedException public boolean java.lang.Object.equals(java.lang.Object) public java.lang.String java.lang.Object.toString() public native int java.lang.Object.hashCode() public final native java.lang.Class java.lang.Object.getClass() public final native void java.lang...

Reflections in Java

Image
Reflections in Java Reflection enables Java code to discover information about the fields, methods and constructors of loaded classes, and to use reflected fields, methods, and constructors to operate on their underlying counterparts, within security restrictions. The API accommodates applications that need access to either the public members of a target object (based on its runtime class) or the members declared by a given class. It also allows programs to suppress default reflective access control. (Source : Oracle) Our First Program for understanding reflections in Java 1. For using reflections we have to import package names java.lang.reflect  import java.lang.reflect.*; abstract class A { } class DesiExplanation { public static void main(String ar[]) { Class cc=A.class; System.out.println(Modifier.isAbstract(cc.getModifiers())); } } Fun Fact : Java means cup of tea but it isn't everyone's cup of tea ~ Krishan Kumar