Beruflich Dokumente
Kultur Dokumente
Pyramid
2. class p1 {
3.
public static void main(String agrs[]) {
4.
System.out.println("The Pattern is");
5.
for (int i = 0; i < 5; i++) {
6.
for (int j = 0; j < 5; j++) {
7.
if (j <= i) {
8.
System.out.print(" $");
9.
} else {
10.
System.out.print("
");
11.
}
12.
}
13.
System.out.println();
14.
}
15.
}
16. }
feb[1] = 1;
for(int i=2; i < febCount; i++){
feb[i] = feb[i-1] + feb[i-2];
}
6. Number Palindrome
import java.util.Scanner;
class Palindrome{
public static void main(String args[]){
System.out.print("Enter Number: ");
Scanner read = new Scanner(System.in);
int num = read.nextInt();
int n = num;
//reversing number
int rev=0,rmd;
while(num > 0)
{
rmd = num % 10;
rev = rev * 10 + rmd;
num = num / 10;
}
if(rev == n)
System.out.println(n+" is a Palindrome Number!");
else
System.out.println(n+" is not a Palindrome Number!");
}
}
7. Title case
Upper case
String s1 = t1.getText();
String s2 = s1.toUpperCase();
T2.setText(s2);
Lower Case
String s1=t1.getText();
String s2=s1.toLowerCase();
T2.setText(s2);
3. pubic
Package abc;
Public class AccessDemo
{
Public void test()
{
System.out.println(Example of public class);
}
}
Protected
Class AccessDemo
{
Protected int x = 34;
{
System.out.println(The variables is+x);
}
Class childAccessextendAccessDemo
{}
Public class Access Example.
{
Public static void main(String args[]){
childAccess ca = new childAccess();
ca.showDemo();
ca.X=45;
Private
Class AccessDemo
{
Private int x = 56;
Public void showDemo()
{
System.out.println(the Variable is + x);
}
Private void test Demo
{
System.out.println(It cant be accessed in another class);
}}
Public class Access Example
{
Public static void main(String args[]){
AccessDemo Ad = new AccessDemo();
Ad.testDemo();
Ad.X=5;
Ad.showDemo();
Ad.showDemo();
}
}
s4="M";
else
s4="F";
s5=c1.getSelectedItem().toString();
s6=t4.getText();
int i1=Integer.parseInt(s1);
int i2=Integer.parseInt(s3);
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/abhinav","root","ssgs");
Statement st=con.createStatement();
String q="insert into student values("+i1+",'"+s2+"',"+i2+",'"+s4+"','"+s5+"','"+s6+"');";
st.executeUpdate(q);
}
catch(Exception e){System.out.println(e);}