java class file name ( printName.java): Run: on page R.B click - run on server
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
// Following statement would create an object myPuppy
printName myPuppy = new printName( );
myPuppy.Puppy(kaniz);
myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
System.out.println(date);
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
Also follow it
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
Name("rokon");
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public static void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
// private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
printName myPuppy = new printName( );
// Following statement would create an object myPuppy
Puppy(kaniz);
myPuppy. Name("rokon");
// myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
Date date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
System.out.println(date);
}
private static Date date = new Date();
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
newTestList.java
public class newTestList {
public int sum(int a,int b){
int s = 0;
s = a+b;
System.out.println(s);
printName.Puppy("owares");
printName bas = new printName();
bas.Name("iftekhar");
return s;
}
public int sum(int a,int b,int c){
int s= 0;
s = a+b+c;
System.out.println(s);
return s;
}
public static void main(String[] args) {
newTestList p = new newTestList();
p.sum (10,20);
p.sum (10,20,50);
}
}
3rd Step static and non static
printName.java
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
Name("rokon");
Puppy("");
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public static String Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
return "";
}
static void strat() {
}
// private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
printName myPuppy = new printName( );
strat();
// Following statement would create an object myPuppy
System.out.println(printName.Puppy("pop"));
System.out.println(Puppy("popppp"));
// printName.
// Puppy(kaniz);
// myPuppy. Name("rokon");
// myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
Date date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
//System.out.println(date);
}
private static Date date = new Date();
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
newTestList.java
public class newTestList {
public int sum(int a,int b){
int s = 0;
s = a+b;
System.out.println(s);
printName.Puppy("owares");
printName bas = new printName();
bas.Name("iftekhar");
bas.Puppy("");
bas.getDate();
return s;
}
public int sum(int a,int b,int c){
int s= 0;
s = a+b+c;
System.out.println(s);
return s;
}
public static void main(String[] args) {
newTestList p = new newTestList();
p.sum (10,20);
p.sum (10,20,50);
}
}
** java action class run and see output(printName.java)
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
// Following statement would create an object myPuppy
printName myPuppy = new printName( );
myPuppy.Puppy(kaniz);
myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
}
}
output
Passed(call by reference) Name is :null
Passed(value) Name is op is double cotation kaniz:kaniz. I am string value.it is direct value pass
Passed(value) Name is :kanizZZ Passed(value) nameNext is : fatema
Passed(call by reference) Name k is :ghrg Passed(call by reference ) nameNext f is : fatema mmm Passed ( direct vallue call) text is :kkkkk Call by Reference Numbers : 100
**************************************************************************
Write a method to print out a string “Name” multiple times
==========================================================
System.out.println("name" + " " + "name" + " "...).
1/ "name"
2/ + " "
3/ + "name"
4/ + " "
update printName.java
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
// Following statement would create an object myPuppy
printName myPuppy = new printName( );
myPuppy.Puppy(kaniz);
myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
System.out.println(date);
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
// Following statement would create an object myPuppy
printName myPuppy = new printName( );
myPuppy.Puppy(kaniz);
myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
System.out.println(date);
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
Also follow it
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
Name("rokon");
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public static void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
// private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
printName myPuppy = new printName( );
// Following statement would create an object myPuppy
Puppy(kaniz);
myPuppy. Name("rokon");
// myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
Date date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
System.out.println(date);
}
private static Date date = new Date();
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
newTestList.java
public class newTestList {
public int sum(int a,int b){
int s = 0;
s = a+b;
System.out.println(s);
printName.Puppy("owares");
printName bas = new printName();
bas.Name("iftekhar");
return s;
}
public int sum(int a,int b,int c){
int s= 0;
s = a+b+c;
System.out.println(s);
return s;
}
public static void main(String[] args) {
newTestList p = new newTestList();
p.sum (10,20);
p.sum (10,20,50);
}
}
3rd Step static and non static
printName.java
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
Name("rokon");
Puppy("");
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public static String Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
return "";
}
static void strat() {
}
// private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
printName myPuppy = new printName( );
strat();
// Following statement would create an object myPuppy
System.out.println(printName.Puppy("pop"));
System.out.println(Puppy("popppp"));
// printName.
// Puppy(kaniz);
// myPuppy. Name("rokon");
// myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
Date date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
//System.out.println(date);
}
private static Date date = new Date();
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
newTestList.java
public class newTestList {
public int sum(int a,int b){
int s = 0;
s = a+b;
System.out.println(s);
printName.Puppy("owares");
printName bas = new printName();
bas.Name("iftekhar");
bas.Puppy("");
bas.getDate();
return s;
}
public int sum(int a,int b,int c){
int s= 0;
s = a+b+c;
System.out.println(s);
return s;
}
public static void main(String[] args) {
newTestList p = new newTestList();
p.sum (10,20);
p.sum (10,20,50);
}
}
** java action class run and see output(printName.java)
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
// Following statement would create an object myPuppy
printName myPuppy = new printName( );
myPuppy.Puppy(kaniz);
myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
}
}
output
Passed(call by reference) Name is :null
Passed(value) Name is op is double cotation kaniz:kaniz. I am string value.it is direct value pass
Passed(value) Name is :kanizZZ Passed(value) nameNext is : fatema
Passed(call by reference) Name k is :ghrg Passed(call by reference ) nameNext f is : fatema mmm Passed ( direct vallue call) text is :kkkkk Call by Reference Numbers : 100
**************************************************************************
Write a method to print out a string “Name” multiple times
==========================================================
System.out.println("name" + " " + "name" + " "...).
1/ "name"
2/ + " "
3/ + "name"
4/ + " "
update printName.java
import java.util.Date;
public class printName {
public void NameMore(String name,String nameNext){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is :" + name +" Passed(value) nameNext is : " + nameNext );
}
public void NameMoreRefPas(String name,String nameNext,String text,int number){
// This constructor has one parameter, name.
System.out.println("Passed(call by reference) Name k is :" + name +" Passed(call by reference ) nameNext f is : " + nameNext +" Passed ( direct vallue call) text is :" + text +" Call by Reference Numbers : " +number);
}
//*************************************************************
public void Name(String name){
// This constructor has one parameter, name.
System.out.println("Passed(value) Name is op is double cotation kaniz:" + name );
}
public void Puppy(String name){
// This constructor has one parameter, name.
// System.out.println("Passed(value) Name is :" + name );
System.out.println("Passed(call by reference) Name is :" + name );
}
private static Date date = null;
public static void main(String []args){
String callByReference = null;
String kaniz;
kaniz = callByReference;
// Following statement would create an object myPuppy
printName myPuppy = new printName( );
myPuppy.Puppy(kaniz);
myPuppy.Name("kaniz. I am string value.it is direct value pass");
//*********************************************************************
//String fatema = null;
myPuppy.NameMore("kanizZZ","fatema");
String referenceKaniz="ghrg";
//String referenceKaniz = null;
//String k = null;
// String f = null;
String k = referenceKaniz;
String f = "fatema mmm";
int i = 100;
myPuppy.NameMoreRefPas(k,f,"kkkkk",i);
date = new Date(); // This line is non static; But this non static can not call in static method. So I would this line static method.That means : above line private static Date date = null;
System.out.println(date);
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
it's good but try to follow the naming convention. A class name always start with capital letter and a variable and method name start with small letter.
ReplyDelete