Jump to content

Recommended Posts

Posted

[quote name='hava' timestamp='1344040612' post='1302254740']
[color=#282828][font=helvetica, arial, sans-serif][size=6]Operations o =[/size][/font][/color]
[b][color=#7F0055]new[/color][/b][color=#282828][font=helvetica, arial, sans-serif][size=6] Oparations() ; ee line ni explain chy mama *<:([/size][/font][/color]
[/quote]

See let us say u have package called calculator in that there is class called Oparations so now ihave to use them
it is written by you and i a user using ur Caludulator

See now

PAckage myPackage; //this is nothing to do urs

import Calulator.Oparations ; ///this is ur class u will give me in the far a jar file and that jar file will be in my class path no need to give code

public class MyClass { // this my class and i am using ur class

[color=#282828][font=helvetica, arial, sans-serif][size=6]Operations o =[/size][/font][/color][b][color=#7F0055]new[/color][/b][color=#282828][font=helvetica, arial, sans-serif][size=6] Oparations() ; // i ma intializing your class here so that i can use ur methods add and sub[/size][/font][/color]
public int add(int num1 , int num2)
{
return o.add(num1.num2) ;// now i can use ur method add like this
}

}

so to use any other class in ur class u have to do like that

let me give some simple example

String s = "chinna" ;
or String s = new String("chinna") ;
or
String s = new String() ;

s = "chinna" ;

This is how i used Sttring class here since String has multiple constructors we can use it multiple ways

Oprations has only one constructor

if in oprations class if u have a constrcutor like

public class Oparation{

public Oprations(int num1, int num2)

{
}//then we uses Opration o = new Opration(10,12)

}


let me know if this not clear

  • Replies 103
  • Created
  • Last Reply

Top Posters In This Topic

  • hava

    44

  • cherlapalli_jailer

    17

  • soulmate

    11

  • Aamayakudu

    7

Top Posters In This Topic

Posted

It is instantiation/instantiating and not initialization/ing

initializing ante edhi o.name = 'abc' ;

[quote name='cherlapalli_jailer' timestamp='1344041273' post='1302254776']
See let us say u have package called calculator in that there is class called Oparations so now ihave to use them
it is written by you and i a user using ur Caludulator

See now

PAckage myPackage; //this is nothing to do urs

import Calulator.Oparations ; ///this is ur class u will give me in the far a jar file and that jar file will be in my class path no need to give code

public class MyClass { // this my class and i am using ur class

[color=#282828][font=helvetica, arial, sans-serif][size=6]Operations o =[/size][/font][/color][b][color=#7F0055]new[/color][/b][color=#282828][font=helvetica, arial, sans-serif][size=6] Oparations() ; // i ma [/size][/font][/color][b][color=#ff0000][font=helvetica,arial,sans-serif][size=6]intializing [/size][/font][/color][/b][color=#282828][font=helvetica,arial,sans-serif][size=6]your class here so that i can use ur methods add and sub[/size][/font][/color]
public int add(int num1 , int num2)
{
return o.add(num1.num2) ;// now i can use ur method add like this
}

}

so to use any other class in ur class u have to do like that

let me give some simple example

String s = "chinna" ;
or String s = new String("chinna") ;
or
String s = new String() ;

s = "chinna" ;

This is how i used Sttring class here since String has multiple constructors we can use it multiple ways

Oprations has only one constructor

if in oprations class if u have a constrcutor like

public class Oparation{

public Oprations(int num1, int num2)

{
}//then we uses Opration o = new Opration(10,12)

}


let me know if this not clear
[/quote]

Posted

[quote name='hava' timestamp='1344041197' post='1302254768']

mama okete primitive data type use chesthunnam kadha int ani... y need of type casting mama

int x = 5;

double y = 300.76736736378d;

int result z = x*y;

ila unnappudu kadh type casting use chestham? :(
[/quote]

primitive types ne kadu objects ni kuda cheyachu....

aakada nuvu sub class object create chesav kani adhi super class object kavali ani aduguthundhi....

so (Calc)o.add() use cheyee

Posted

[quote name='ChampakDas' timestamp='1344041524' post='1302254789']
It is instantiation/instantiating and not initialization/ing

initializing ante edhi o.name = 'abc' ;
[/quote]

correct typo mistake and/or negligence thats all thanks
it seems he is new to java so i am givnig some basics

Posted
:3D_Smiles: (.L@ (.L@ (.L@ [quote name='Aamayakudu' timestamp='1344041577' post='1302254793']
primitive types ne kadu objects ni kuda cheyachu....

aakada nuvu sub class object create chesav kani adhi super class object kavali ani aduguthundhi....

so (Calc)o.add() use cheyee
[/quote]
Posted
:4_12_13: [quote name='cherlapalli_jailer' timestamp='1344041681' post='1302254800']
correct typo mistake and/or negligence thats all thanks
it seems he is new to java so i am givnig some basics
[/quote]
Posted

hello hava type ur doubts in pm or here i will respond t'row its already 9pm i have to log off

Posted

[quote name='cherlapalli_jailer' timestamp='1344041681' post='1302254800']
correct typo mistake and/or negligence thats all thanks
it seems he is new to java so i am givnig some basics
[/quote]
bhayya nuvu ichina code lo u declared num1 =100 and num2 =50 in main method ila kakunda how pass arguments I mean run time lo num1= ?

and num2 =? suppose two different numbers isthe add and subtract methods invoke ayyettu... amayakudu mama cheppindhi cheyyala type casting? sCo_^Y

Posted

[quote name='cherlapalli_jailer' timestamp='1344041789' post='1302254810']
hello hava type ur doubts in pm or here i will respond t'row its already 9pm i have to log off
[/quote]
last doubt agiga adhi cheppesi vellu *<:(

Posted

Cool...nice to hear
[quote name='cherlapalli_jailer' timestamp='1344041681' post='1302254800']
correct typo mistake and/or negligence thats all thanks
it seems he is new to java so i am givnig some basics
[/quote]

Posted

you have5 ?
[quote name='hava' timestamp='1344041728' post='1302254804']
:4_12_13:
[/quote]

Posted

[quote name='ChampakDas' timestamp='1344042067' post='1302254829']
you have5 ?
[/quote]
yeah its me sSc_hidingsofa please clear my above mentioned doubt

Posted

[quote name='hava' timestamp='1344039600' post='1302254688']
:3D_Smiles: :3D_Smiles: endhi mama nuvvu
[/quote]emaindi mama..

Posted

[quote name='hava' timestamp='1344042023' post='1302254824']
last doubt agiga adhi cheppesi vellu *<:(
[/quote]

yep go a head

Posted

[quote name='hava' timestamp='1344041997' post='1302254822']
bhayya nuvu ichina code lo u declared num1 =100 and num2 =50 in main method ila kakunda how pass arguments I mean run time lo num1= ?

and num2 =? suppose two different numbers isthe add and subtract methods invoke ayyettu... amayakudu mama cheppindhi cheyyala type casting? sCo_^Y
[/quote]
mama idhe mama na doubt

×
×
  • Create New...