Posts

Toast

Image
  TOAST   A Toast is short message display on the screen. Toast provide simple feedback message with a popup message. Toast automatically disappear after a timeout. Example :-   clicking  Send  on an email triggers a "Sending message..." toast. Context context = getApplicationContext (); CharSequence text = "Hello Shraddha Nand Pandey" ; int duration = Toast . LENGTH_SHORT ; Toast toast = Toast . makeText ( context , text , duration ); toast . show ();// in built function to show toast XML CODE:- <? xml version ="1.0" encoding ="utf-8" ?> < androidx.constraintlayout.widget.ConstraintLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" tools :context =".MainActiv

Dice Roller App using Java

Image
 Dice Roller App using  Java In Android Studio <? xml version ="1.0" encoding ="utf-8" ?> < androidx.constraintlayout.widget.ConstraintLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" android :background ="#29b6f6" tools :context =".MainActivity" > < ImageView android :id ="@+id/Image_view_dice" android :layout_width ="300dp" android :layout_height ="300dp" android :onClick ="play" android :src ="@drawable/one" app :layout_constraintBottom_toBottomOf ="parent" app :layout_constraintLeft_toLeftOf ="parent" app :layout_constraintR

Single Music Player App in Android Studio

Image
 Music Player App in   Android Studio  Xml code:- <? xml version ="1.0" encoding ="utf-8" ?> < androidx.constraintlayout.widget.ConstraintLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" tools :context =".MainActivity" > < TextView android :id ="@+id/textView" android :layout_width ="149dp" android :layout_height ="40dp" android :background ="#2196F3" android :gravity ="center" android :shadowColor ="#FFFFFF" android :text ="Music Player" android :textColor ="#FFFFFF" android :textSize ="24sp" android :text

SWAPPING OF TWO NUMBER WITHOUT USING THIRD VARIABLE (XOR Bitwise operator)

 SWAPPING OF TWO NUMBER WITHOUT USING THIRD VARIABLE  (XOR Bitwise operator)  with the use of XOR bitwise operator we can swap two number without using third variable XOR(^) : help to inverse the binary or decimal number         ALGORITHM  Take two variable a and b assign value of a and b  (as we assign a=10 and b=15) then a = a^b ( value of a will change to 5 )           because   a  =10 =1 0 1 0  |    only one bit should be 1 so                           b =15 = 1 1 1 1  |    answer will be 1 or true                          a ^ b  =  0 1 0 1    .i.e. 5 now b = a^b (here a = 5 and b = 15) then, value of b =10           because    a  =5   =  0 1 0 1                               b =15 =  1 1 1 1                          a ^ b  =   1 0 1 0     a = a^b ( value of a will swap to 15)           because    a  =5   =  0 1 0 1                               b =10 =  1 0 1 0                         a ^ b  =   1 1 1 1   .i.e. 15   result a =15 and b=10 Java code    package com.company ; import

BITWISE OPERATOR

BITWISE OPERATOR package com.company ; public class Main { public static void main ( String [] args ) { //AND operator int x = 10 , y = 6 , z ; z = x & y ; //both bits should be 1 /* x y x&y 0 0 0 0 1 0 1 0 0 1 1 1 */ System . out . println ( "z=x&y : " + z ); //OR bitwise operator z = x | y ; //one of bits should be 1 /* x y x|y 0 0 0 0 1 1 1 0 1 1 1 1 */ System . out . println ( "z=x|y : " + z ); //XOR bitwise operator z = x ^ y ; //only one bits should be 1 /* x y x^y 0 0 0 0 1 0 1 0 0 1 1 0 */ System . out . println ( "z=x^y : " + z ); /*LEFT SHIFT operator * It will double the number by moving 1 place * Automati

Queue

Image
 Queue     Demonstration of queue using linked list in JAVA    package com.company ; import java.util. Queue ; import java.util.LinkedList ; public class Main { public static void main ( String [] args ) { // write your code here Queue < Integer > q = new LinkedList <> (); q . add ( 10 ); q . add ( 1 ); q . add ( 8 ); q . add ( 4 ); q . add ( 7 ); q . add ( 89 ); System . out . println ( "The queue is: " + q ); } } The queue is: [10, 1, 8, 4, 7, 89] Process finished with exit code 0 Show peak of queue    package com.company ; import java.util. Queue ; import java.util.LinkedList ; public class Main { public static void main ( String [] args ) { // write your code here Queue < Integer > q = new LinkedList <> (); q . add ( 6 ); q . add ( 1 ); q . add ( 8 ); q . add ( 4 ); q . add ( 7 ); q . add ( 89 ); System