signin
Android studio IDE Description Tutorial for Beginners Step By Step :
Last Updated on: 12th Jul 2025 02:01:50 AM
In this tutorial we learn all about android studio IDE(Integrated Development Environment) and Project Structure.it is bassed on IntelliJ IDEA .
Project Structure windows :
When you open android studio by Default, it will show you project structure in android project view. this project view is organized into two modual with source code files and resource files .first is App Modual and Second is Gradle Scripts modual.
Further app modual contains following another Modual:
- manifests : This modual contains the AndroidManifest.xml file.it is a predefined xml file which contain all details about the app.like app name , app theme , activity , services , broadcast receiver etc.bassically describes the structure of an Android app.
- java : It contains java file which is sourse code of an app.
- res :It contain resources file of an app.which are also orgamized in drawable ,layout,mipmap and values Modual.
- drawable :drawable directory stores xml file which is all about graphics that is used to design for screen View and contain images and which is saved.you can add custom design to your view or UI elements . supoose we need design diffrent background gradient color of Button or other views .then we create a Drawable xml file and add it in the background of View.
- layout : This directory is used to store Layout xml file of our application (activity_main.xml).and Layout xml File is used to define structure of user Interface(UI).it holds all view and provide possition.such as EditText, Button and other UI elements.
- mipmap : It containining app launcher icons of different resolutions and other icons that that you would be using in your application .
- values : this modual folder holds some predefined xml file such as colors.xml, string.xml, styles.xml and dimens.xml file.
Uses of Xml file in Values Folder :
- colors.xml : This is a predefined xml file which is use to define the color codes for our application.you can modify according to your need and used them in our app from this file.
- string.xml : This xml file is used to store all of the string you would like to display (in Activity or Layout )to the user. You can create strings by adding a new string element and then excess them in your app from this xml file.
- dimens.xml : This xml file is used to define the dimensions of the UI elements.Suppose we need a Button with 50dp(density pixel) height then we define the value 50dp in dimens.xml file and then use it in our app from this file.
- styles.xml : The style xml file store default theme and style for your app .you can also create custom style and theme and provide new look of (User Interface) your app .
Method overloading
public class ShoppingCart {
// Method to add items to the cart
public void addItem(String itemName)
{
// Logic to add a single item to the cart.
System.out.println(itemName + " added to the cart.");
}
// Overloaded method to add items with quantity.
public void addItem(String itemName, int quantity)
{
// Logic to add multiple items with a specific quantity to the cart.
System.out.println(quantity + " " + itemName + "s added to the cart.");
}
// Overloaded method to add items with quantity and price.
public void addItem(String itemName, int quantity, double price)
{
// Logic to add items with quantity and price to the cart.
double totalCost = quantity * price;
System.out.println(quantity + " " + itemName + "s added to the cart. Total cost: $" + totalCost);
}
public static void main(String[] args)
{
// Creating an instance of class shoppingCart.
ShoppingCart cart = new ShoppingCart();
// Calling methods by passing argument values.
cart.addItem("T-shirt");
cart.addItem("Shoes", 2);
cart.addItem("Sunglasses", 3, 25.99);
}
}
Output: T-shirt added to the cart. 2 Shoes added to the cart. 3 Sunglasses added to the cart. Total cost: $77.97
Example 2 method overloading
we are building an online shopping cart where we calculate the price of items in multiple ways based on different parameters like quantity, discount, or additional tax.
class ShoppingCart {
// Method to calculate price for a single item with its price
double calculatePrice(double price) {
return price;
}
// Overloaded method to calculate price with quantity
double calculatePrice(double price, int quantity) {
return price * quantity;
}
// Overloaded method to calculate price with quantity and discount
double calculatePrice(double price, int quantity, double discountPercentage) {
double total = price * quantity;
double discount = total * (discountPercentage / 100);
return total - discount;
}
// Overloaded method to calculate price with tax
double calculatePrice(double price, int quantity, double discountPercentage, double taxPercentage) {
double total = calculatePrice(price, quantity, discountPercentage); // Reuse method
double tax = total * (taxPercentage / 100);
return total + tax;
}
}
public class MethodOverloadingExample {
public static void main(String[] args) {
ShoppingCart cart = new ShoppingCart();
// Calling different overloaded methods
System.out.println("Price for single item: " + cart.calculatePrice(100.0));
System.out.println("Price for 5 items: " + cart.calculatePrice(100.0, 5));
System.out.println("Price for 5 items with 10% discount: " + cart.calculatePrice(100.0, 5, 10));
System.out.println("Price for 5 items with 10% discount and 5% tax: " + cart.calculatePrice(100.0, 5, 10, 5));
}
}
Example : 3 Method Overloading :
class MathOperations {
// Method overloading for integer addition
public int add(int a, int b) {
return a + b;
}
// Method overloading for double addition
public double add(double a, double b) {
return a + b;
}
// Method for string concatenation
public String concatenate(String a, String b) {
return a + b;
}
// Method for array sum
public int add(int[] numbers) {
int sum = 0;
for (int num : numbers) {
sum += num;
}
return sum;
}
// More methods...
}
public class Demo {
public static void main(String[] args) {
MathOperations m = new MathOperations();
int num[] = { 3, 4, 54, 6, 7 };
int r = m.add(num);
System.out.println(r);
}
}
Method Overriding :
class Animal {
void makeSound() {
System.out.println("Some generic sound");
}
}
class Dog extends Animal {
void makeSound() {
System.out.println("Bark");
}
}
class Cat extends Animal {
void makeSound() {
System.out.println("Meow");
}
}
class Horse extends Animal {
void makeSound() {
System.out.println("Neigh");
}
}
class Bird extends Animal {
void makeSound() {
System.out.println("Chirp");
}
}
public class Demo {
public static void main(String[] args) {
Animal dog = new Dog();
Animal cat = new Cat();
Animal horse = new Horse();
Animal bird = new Bird();
dog.makeSound(); // Output: Bark
cat.makeSound(); // Output: Meow
horse.makeSound(); // Output: Neigh
bird.makeSound(); // Output: Chirp
}
}
abstraction example
// Java Program to implement
// Java Abstraction
// Abstract Class declared
abstract class Animal {
private String name;
public Animal(String name) { this.name = name; }
public abstract void makeSound();
public String getName() { return name; }
}
// Abstracted class
class Dog extends Animal {
public Dog(String name) { super(name); }
public void makeSound()
{
System.out.println(getName() + " barks");
}
}
// Abstracted class
class Cat extends Animal {
public Cat(String name) { super(name); }
public void makeSound()
{
System.out.println(getName() + " meows");
}
}
// Driver Class
public class Demo {
// Main Function
public static void main(String[] args)
{
Animal myDog = new Dog("Buddy");
Animal myCat = new Cat("Fluffy");
myDog.makeSound();
myCat.makeSound();
}
}