0% found this document useful (0 votes)
55 views3 pages

Java Programming Assignments

This document contains code snippets for three Java programs: 1) A program to implement string class methods that prints a string created from a character array. 2) A program to sort an integer array using the Arrays.sort method. 3) A program to display a string using an Applet by drawing the string in the paint method.

Uploaded by

Ankush Halder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views3 pages

Java Programming Assignments

This document contains code snippets for three Java programs: 1) A program to implement string class methods that prints a string created from a character array. 2) A program to sort an integer array using the Arrays.sort method. 3) A program to display a string using an Applet by drawing the string in the paint method.

Uploaded by

Ankush Halder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Techno India University

NAME : SAYAN BISWAS


STUDENT-ID : 181001102082
BATCH : BCA(2A)
SUB : PROGRAMMING IN JAVA
24) Write a java program to implement different string class methods
ode -
1
2 class p24 {
3
4 public static void main(String args[]) {
5 char[] arr = { 'h', 'e', 'l', 'l', 'o',' ','w','o','r','l','d' };
6 String arr2 = new String(arr);
7 System.out.println( arr2 );
8 }
9 }
utput
>> PS C:\Users\Sayan\Desktop\new\College java programs> java p24
>>
>> hello world
25) Write a java program to implement sorting of 10 integer numbers
ode -
1 import java.util.Arrays;
2 class p25{
3 public static void main(String... args) {
4 int[] arr={12,5,6,11,99,0};
5 Arrays.sort(arr);
6 for(int in:arr)
7 System.out.println(in);
8 }
9 }
utput
>> PS C:\Users\Sayan\Desktop\new\College java programs> java p9
>>
>> 0
>> 5
>> 6
>> 11
>> 12
>> 99
26) Write a java program to display string by using applet
ode -
1
2 import java.applet.*;
3 import java.awt.*;
4 //<applet code="p26.class" height="200" width="300"></applet>
5 public class p26 extends Applet{
6 public void paint(Graphics g){
7
8 g.drawString("hello applets",50,30);
9 }
10 }
utput
>> C:\Users\Sayan\Desktop\new\College java programs> javac p26.java
>> C:\Users\Sayan\Desktop\new\College java programs> appletviewer p26.java
>>

You might also like