What do you want to save?
Add Code snippet
New code examples
-
Java 2021-10-28 09:47:06
why we use static in java
//Java Program to get the cube of a given number using the static method using static before a method or variable we can access it by not creating a instance of it.in the program we directly used student.cube(5) class Calculate{ static int cube(int... Add solution -
Java 2021-10-17 21:53:05
abstraction example in java
bstraction: Hiding the implementation details, concentrating on essentials things, without worrying about the details ■ In java, abstraction is achieved via abstract class or interface ■ Abstraction cannot exist without inheritance 3.1. Abstract cla... Add solution -
Python 2021-10-17 17:14:04
@classmethod vs @staticmethod vs "plain" methods
# @classmethod vs @staticmethod vs "plain" methods # What's the difference? class MyClass: def method(self): """ Instance methods need a class instance and can access the instance through `self`. ... Add solution -
Java 2021-10-15 18:48:20
static data and static methods in java
class JavaExample{ private static String str = "BeginnersBook"; //Static class static class MyNestedClass{ //non-static method public void disp() { /* If you make the str variable of outer class * non-static then you will g... Add solution -
Java 2021-10-15 04:20:05
difference between integer and int
int is a primitive type. Variables of type int store the actual binary value for the integer you want to represent. int.parseInt("1") doesn't make sense because int is not a class and therefore doesn't have any methods. Integer is a class, no d... Add solution -
Python 2021-10-13 00:50:05
class methods in python
#To create a static method, just add "@staticmethod" before defining it. >>>class Calculator: # create static method @staticmethod def multiplyNums(x, y): return x * y >>>print('Product:', Calculator.multi... Add solution -
PHP 2021-10-12 01:12:09
session variable in laravel
/** * Static method */ Session::put('key', $value); // Set session variable Session::get('key') // Get session variable /** * Instance method */ session(['key' => $value]); // Set session variable session('key'); // Get session variable Add solution -
C# 2021-10-05 03:15:02
c# system classes
// ----------------- LIST OF SOME SYSTEM CLASSES ---------------------// // ______Class StringBuilder______ // Creates an object that represents a mutable string of characters using System.Text; StringBuilder myText = new StringBuilder(); myText.Appen... Add solution -
Java 2021-09-21 00:27:03
number to words java
class NumberToWordExample1 { //user-defined static method that converts a number into words static void numberToWords(char num[]) { //determines the number of digits in the given number int len = num.length; //checks the given number has nu... Add solution -
Other 2021-09-19 15:01:04
instance methods
static or class method 1) A method that is declared as static is known as the static method 2) We don't need to create the objects to call the static methods 3) Non-static (instance) members cannot be accessed in static context (static method, static blo... Add solution