Posts

How to Set Orientation in React Native App Without using any package

Controlling Orientation on Android For Android, you can control the orientation of your React Native app by modifying the AndroidManifest.xml file located in the android/app/src/main directory of your project. Follow these steps: Open the AndroidManifest.xml file. Locate the <activity> tag for your main activity, which is typically named .MainActivity . To set your app to landscape mode, add the following attribute to the <activity> tag: xml android:screenOrientation="landscape" Your <activity> tag should now look something like this: xml < activity android:name = ".MainActivity" android:label = "@string/app_name" android:configChanges = "keyboard|keyboardHidden|orientation|screenSize|uiMode" android:screenOrientation = "landscape" android:windowSoftInputMode = "adjustResize" > To set your app to portrait mode, simply change the value of android:screenOrientation to "portrait...

Datatypes in java

Data Types In Java There are two data types available in Java: 1.Primitive Data Types 2.Reference/Object Data Types  (Non Primitive) Primitive Data Types: There are eight primitive data types supported by Java. Primitive data types are predefined by the language and named by a keyword. The eight primitive data types are explained below: byte: Byte data type is an 8-bit signed two's complement integer. Minimum value is -128 (-2^7) Maximum value is 127 (inclusive)(2^7 -1) Default value is 0 Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int. Example: byte a = 100 , byte b = -50 short: Short data type is a 16-bit signed integer.  Minimum value is -32,768 (-2^15) Maximum value is 32,767 (inclusive) (2^15 -1) Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int Default value is 0. Example: short s = 10000, short r = -20000 int : Int data type is a 32-b...

Type casting in cpp

  Type casting.{short} Reference variable: - Reference variable produces an aliens ( alternative name) feel a precously defined variable. Syntax:- data type &reference_variable_nm=variable_nm ; Ex:-int sum=100; int &total=sum; ⇒ handsome is the inter type variable that has already been declared and total is the alternative name declared to the present variable sum. cout<<sum; cout<<total; ⇒ Both statement prints the value 100 Sum=sum+20; Will change the value of both total and sum. ⇒A reference variable must be initialised at the time of declaration. ⇒Hence, both the variable sum and the total reference to the same letter object in the memory. ⇒Hence, "&" percent is not an address operator. Program on reference variable. #include<iostream.h> int main() { int sum=200; int & total=sum; cout<<"sum="<<sum<<"\ntotal="<<total; sum=sum+30; cout<<"\nsum="<<sum<<"\ntotal...

Scope resolution in cpp

  Scope Resolution Operator This operator is used to access the Global variable but also has a local variable with a same variable name. Syntax:- ::Variable_name;  Return type<class_name>::method_name() { State_1; State_2; : : } ↣It used to define number of functions outside of the class.                           Ex:- #include<iostream.h> int a=30; int main() { int a=20; cout<<"::a="<<::a<<"\n"; cout<<"a="<<a; return 0; } Out put:- ::a=30 a=20

Java virtual machine(JVM)

  JVM (JAVA VIRTUAL MACHINE) A Java virtual machine (JVM), an implementation of the Java Virtual Machine Specification, interprets compiled Java binary code (called bytecode) for a computer's processor (or "hardware platform"). S that it can perform a Java program's instructions. Java was designed to allow application programs to be built that could be run on any platform without having to be rewritten or recompiled by the programmer for each separate platform. A Java virtual machine makes this possible because it is aware of the specific instruction lengths and other particularities of the platform. JVM generates machine code for its corresponding machine from the byte code.

String handling functions

  Strings String Class  String is a class in java that is final String in Java programming, are a sequence of characters. In the Java programming language, strings are objects. String is also a data type in java  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 Example of String String a="Hello"; String b=new String(); String c=new String("Hello");   Methods in String Class   Basic Methods 1. s.concat(String s2) Concatenates one string onto another. Appends the String s2 to the String s. Example: String str1 = new String("Hello "); String str2 = new String("World"); String str3 = str1.concat(str2); System.out.println(str3); The output  is "Hello World":   2. s.length()   Returns the length of the string. Example: String str1 = new String("Hello "); int n=str1.length(); System.out.println("L...

Looping statements

while () Statement:          This executes a block of statements as long as a specified condition is true. Syntax : while(condition) { statement(s); } next_statement; The (condition) may be any valid Java expression. The statement(s) may be either a single or a compound (a block) statement. Execution : When program execution reaches a while statement, the following events occur: The (condition) is evaluated. If (condition) evaluates as false the while statement terminates and execution passes to the first statement following statement(s) that is the next_statement. If (condition) evaluates as true the  statement(s) iside the loop are executed. Then, the execution returns to step number 1. Example : int i=0;  //Initialize loop variable System.out.println("Even numbers\n"); while(i<=10) { System.out.println(i); i+=2; } do..while()  Statement do..while loop is used when you need to run some statements and processes once at least before checking t...

Constructors in java

Constructors A constructor can be thought of as a specialized method of a class that creates (instantiates) an instance of the class and performs any initialization tasks needed for that instantiation. The sytnax for a constructor is similar but not identical to a normal method. It follows the rules mentioned below The name of the constructor must be exactly the same as the class it is in. Constructors may be private, protected or public. A constructor cannot have a return type (even void). This is what distinguishes a constructor from a method. Multiple constructors may exist, but they must have different signatures, i.e. different numbers and/or types of input parameters. Default constructor: If you don't define a constructor for a class, a default parameter less constructor is automatically created by the compiler. The default constructor calls the default parent constructor (super()) and initializes all instance variables to default value (zero for numeric types, null for objec...

Control statements

Conditional control statements in java Conditional control or decision making is done in java with if statements and switch statement. Simple if() Ensures that a statement is executed only when a condition is true.  Conditions typically involve comparison of variables or quantities for equality or inequality Syntax :  if(condition)   {       statement;   }   statement;   Example :  if (age >= 18) System. out.println(“You are eligible to vote.”); if ... else() This is two way branching statement  and is an extension of if statement and informs what to do if the condition evaluates to false. Syntax :  if(condition)   {       statement;   }   else   {                              statement;   }   Example : if(a>b) System.out.println("A is big");...

Types of constructors

Image
Type of Constructors. ⇒In C++  a constructor is an special Member function which automatically gets called . Whenever, the object of a class is initialised. ⇒The constructor is defined by defining the Member function or method name and class name are same or similar. ↦There are four types of constructors . They are A】 Default Constructor ⇒Constructor are accessed automatically, when the object is initialised or created. ⇒ one's object is created constructors are invoked automatically. Syntax:- Class_name <object_name>; Ex:-A.obj; Sample program #include<iostream.h> class x { public: x() { cout<<"Hi shashi"; }}; int main() { x a; return 0; } B】 Parameterized Constructor ⇒In C++, Parametrized Constructor is as like as default constructor .But, the constructor which has the arruguments is known as the Parameterized Constructor. Sample program #include<iostream.h> class area { public: area(double r) { cout<<"area of circle="<<(r*r...