if you want to store the output of a function in a variable, you can use the return keyword. Instead of storing it, if you're going to print it, you needn't use the return keyword.
import java.util.Scanner; public class returntype { int sum(int a,int b) { return a+b; } public static void main(String args[]) { returntype num1 = new returntype(); Scanner scan = new Scanner(System.in); System.out.print("Enter the first number: "); int x = scan.nextInt(); System.out.print("Enter the second number: "); int y = scan.nextInt(); System.out.print("Total value is : "+num1.sum(x,y)); } }
String get_name( String name){ return name; } long get_no(long a){ return a; } public static void main(String[] args) { Scanner scan=new Scanner(System.in); //declaring name System.out.println("enter the name:"); String a=scan.nextLine(); //declaring phone number System.out.println("enter the phone number:"); long no=scan.nextLong(); //calling both function school obj=new school(); String kk= obj.get_name(a); long num=obj.get_no(no); //end result System.out.println("Name:"+kk); System.out.println("number:"+num); } } getting input from user
public class Return { int sum(int a, int b){ return a+b; } String getname(String name){ return name; } public static void main(String[] args){ Return obj = new Return(); int result =obj.sum(2,3); System.out.println(result); String myname =obj.getname("Guruseelan"); System.out.println(myname); } }
import java.util.Scanner; class Addfun { void add(int a, int b){ System.out.println("the sum of value is : " +(a+b)); } void Sub(int a, int b){ System.out.println("the subtracted of value is : " +(a-b));
}void Multi(int a, int b){ System.out.println("the multiple of value is : " +(a*b));
}void divid(int a, int b){ System.out.println("the divid of value is : " +(a/b));
} public static void main(String [] args){ Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); Addfun num = new Addfun(); num.add(a, b); num.Sub(a, b); num.Multi(a, b); num.divid(a, b); } }
int sum(int n1,int n2) { int total = n1+n2; return total; } public static void main(String args[]){ addition scan = new addition(); int total = scan.sum(20,20); System.out.println(total); }} anna inda program correct ah nu check pani slunga
// Online Java Compiler // Use this editor to write, compile and run your Java code online public class hello { int sum (int a ,int b){ int c = a*b; return c; } public static void main(String[] args) { hello multi = new hello(); int d = multi.sum(10,5); System.out.println(d); } }
public class prog1{ String getname() { return "Raj"; } String getphone() { return "I am a iphone user"; } String getaddress() { return "I am from Chennai"; } public static void main(String args[]) { prog1 pro = new prog1(); String My_Name = pro.getname(); System.out.println("The Name which Retun Is :"); System.out.println(My_Name); String My_phone = pro.getphone(); System.out.println("The Phone Which Return is :"); System.out.println(My_phone); String My_Address = pro.getaddress(); System.out.println("The Address Which Return is :"); System.out.println(My_Address); } }
Vera level la irukku pro unga teaching method
Very use full started learning from scrach
Keep it up and all the best!
if you want to store the output of a function in a variable, you can use the return keyword. Instead of storing it, if you're going to print it, you needn't use the return keyword.
Bro vera level..... understand ❤❤❤❤
NICE EXPLANATION BRO!!!
Glad it helped
Well Explanation
Thanks and Keep watching
WAY OF TEACHING IS GOOD BRooo!
Thankyou
@@ErrorMakesClever awesome man, god gifted you great knowledge thank him
💙
Super bro!!! Most confusing keyword explained well
Thanks a lot and happy it helps!
Frist like frist comment bro so, wating for your all videos
int sum(int j, int k){
int rem = j+k;
return rem;
}
public static void main(String[] args) {
Retirn_type save = new Retirn_type();
int reminder = save.sum(23,30);
System.out.println(reminder);
Bro sql full course podunga bro
Well explaination broo❤
Thanks!!
Codingbat Full video poduga bro
import java.util.Scanner;
public class returntype
{
int sum(int a,int b)
{
return a+b;
}
public static void main(String args[])
{
returntype num1 = new returntype();
Scanner scan = new Scanner(System.in);
System.out.print("Enter the first number: ");
int x = scan.nextInt();
System.out.print("Enter the second number: ");
int y = scan.nextInt();
System.out.print("Total value is : "+num1.sum(x,y));
}
}
Guys phone number int use pana kudathu long use pananum
eppadi bro program le red line podureenga
import java.util.Scanner;
public class school{
String get_name( String name){
return name;
}
long get_no(long a){
return a;
}
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
//declaring name
System.out.println("enter the name:");
String a=scan.nextLine();
//declaring phone number
System.out.println("enter the phone number:");
long no=scan.nextLong();
//calling both function
school obj=new school();
String kk= obj.get_name(a);
long num=obj.get_no(no);
//end result
System.out.println("Name:"+kk);
System.out.println("number:"+num);
}
}
getting input from user
Bro name pathula a tha na varanu
(String name ) pathula (string a)
package youtube;
public class Adress {
String getaddress()
{
return "Kanyakumari";
}
public static void main(String[] args) {
Adress obj=new Adress();
String ad= obj.getaddress();
System.out.println("Address:"+ad);
}
}
public class Return {
int sum(int a, int b){
return a+b;
}
String getname(String name){
return name;
}
public static void main(String[] args){
Return obj = new Return();
int result =obj.sum(2,3);
System.out.println(result);
String myname =obj.getname("Guruseelan");
System.out.println(myname);
}
}
import java.util.Scanner;
class Addfun {
void add(int a, int b){
System.out.println("the sum of value is : " +(a+b));
}
void Sub(int a, int b){
System.out.println("the subtracted of value is : " +(a-b));
}void Multi(int a, int b){
System.out.println("the multiple of value is : " +(a*b));
}void divid(int a, int b){
System.out.println("the divid of value is : " +(a/b));
}
public static void main(String [] args){
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
Addfun num = new Addfun();
num.add(a, b);
num.Sub(a, b);
num.Multi(a, b);
num.divid(a, b);
}
}
public class Return{
String getAddress(){
return "1/143, Haji nagar 2nd Street,Kallikkuppam,Ambatur,Chennai-53";
}
public static void main(String[] args){
Return ret=new Return();
String s=ret.getAddress();
System.out.println(s);
}
}
class hi
{
void div(int num1,int num2)
{
System.out.println(num1/num2);
}
void multi(int num1,int num2)
{
System.out.println(num1*num2);
}
void sub(int num1,int num2)
{
System.out.println(num1-num2);
}
public static void main(String[] args)
{
hi nal=new hi();
nal.div(12,3);
nal.multi(45, 2);
nal.sub(69, 35);
}
}
package MJ;
import java.util.Scanner;
public class returnwithstring {
static String Name(String a){
String c=a;
return c;
}
static String Address(String a) {
String c=a;
return c;
}
static int Phone(int a) {
int c=a;
return c;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println("enter the name: ");
String x=sc.nextLine();
System.out.println("enter the address: ");
String y=sc.nextLine();
System.out.println("enter the Phone NO: ");
int z=sc.nextInt();
String name=Name(x);
String add=Address(y);
int phn=Phone(z);
System.out.println(name);
System.out.println(add);
System.out.println(phn);
sc.close();
}
}
package limited;
public class addition {
int sum(int n1,int n2) {
int total = n1+n2;
return total;
}
public static void main(String args[]){
addition scan = new addition();
int total = scan.sum(20,20);
System.out.println(total);
}}
anna inda program correct ah nu check pani slunga
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
public class hello {
int sum (int a ,int b){
int c = a*b;
return c;
}
public static void main(String[] args) {
hello multi = new hello();
int d = multi.sum(10,5);
System.out.println(d);
}
}
public class prog1{
String getname()
{
return "Raj";
}
String getphone()
{
return "I am a iphone user";
}
String getaddress()
{
return "I am from Chennai";
}
public static void main(String args[])
{
prog1 pro = new prog1();
String My_Name = pro.getname();
System.out.println("The Name which Retun Is :");
System.out.println(My_Name);
String My_phone = pro.getphone();
System.out.println("The Phone Which Return is :");
System.out.println(My_phone);
String My_Address = pro.getaddress();
System.out.println("The Address Which Return is :");
System.out.println(My_Address);
}
}
Bro Sql full course podunga
aldready potrukaru bro
@@smartandrew2362 Thank you bro