ArhamTechMind

Java

Java Program to Find Factorial

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, The value of 0! is 1, according to the convention for an empty product  import java.util.Scanner;  public class Factorial {  public static void main(String[] args) {    int num  ,fact=1;    System.out.println(“enter number:”);    Scanner sc=new Scanner(System.in);     num=sc.nextInt();  …

Java Program to Find Factorial Read More »

Reading a String

The String class represents character strings. All string literals in Java programs, such as “abc” , are implemented as instances of this class.Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. Reading a String < import java.util.Scanner;public class ReadString { public static void main(String[] args) { System.out.println(“enter a String: “); Scanner sc …

Reading a String Read More »

Program to find out the Repetition of character in a String

 Repetition of character in a String import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print(“Enter the String : “); String value = sc.nextLine(); //System.out.println(); System.out.print(“Enter the Charcter : “); String ch = String.valueOf((sc.next().charAt(0))); int count=0; for(int i=0;i<value.length();i++) { if((String.valueOf(value.charAt(i))).equalsIgnoreCase(ch)) { count++; } } System.out.println(“The character : …

Program to find out the Repetition of character in a String Read More »

Program to find count of vowels and consonant

Program to find count of vowels and consonant import java.util.Scanner;public class Vowel {public static void main(String[] args) { System.out.println(“enter a string:”); Scanner sc=new Scanner(System.in); String v=sc.nextLine(); int len=v.length(); char[] vw={‘a’,’e’,’i’,’o’,’u’}; int count=0; for(int i = 0 ; i< len;i++) { for(int j = 0; j<5;j++) { if((String.valueOf(v.charAt(i))).equalsIgnoreCase((String.valueOf(vw[j])))) { count++; }  }    } System.out.println(“In this …

Program to find count of vowels and consonant Read More »

Reverse a String in java

1.//Program to write  reverse a string public class Reverse { public static void main(String[] args) { String s=”abcd”; String rs=””; for (int i=s.length()-1;i>=0;i–){ rs=rs+s.charAt(i); } System.out.println(s); System.out.println(rs); }} OutPut : abccba 2. Using StringBuffer(String string) method, reverse the buffer and then converts the buffer into a String with the help of toString() public class StringReverseExample{   …

Reverse a String in java Read More »

Java is Platform Independent.

Why Java is Platform Independent? Note:   C compile prgms are PD (Platform dependent Java compile prgms are PI  (Platform Independent)   Common technologies used in programming are:- Source Code –> Developer written code Compiled Code –> Compiler generated code Executable Code –> the code ready to execute3 Compilation :- process of converting source code to compile code …

Java is Platform Independent. Read More »