Found 31593 Articles for Programming

Golang program to clear the string buffer

Akhil Sharma
Updated on 01-Feb-2023 19:07:48
When a string buffer is cleared, all of the data that was previously stored inside the buffer is deleted. This can be done for a variety of reasons, including when you want to reuse the buffer for fresh data or when the data that is currently in the buffer is no longer required. Here we will understand different techniques of clear a string buffer using go programming language Syntax Reset() Any accumulated data is discarded and the buffer is reset to zero using the Reset() method. The old buffer is essentially replaced with a new one and the old ... Read More

Golang program to check if a string contains a substring

Akhil Sharma
Updated on 01-Feb-2023 19:06:02
A substring is a small string in a string and string in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. A built-in type in Go, the string type can be used in a variety of ways much like any other data type. Syntax strings.Contains(str, substring string) To determine whether a string contains a particular substring, use the Contains(s, substr string) bool function. If the substring is found in the supplied string, a ... Read More

Golang program to show data hiding in class

Akhil Sharma
Updated on 01-Feb-2023 19:04:51
In Golang, data hiding is a practice of preventing external code from accessing or changing a class’s members. This is accomplished by designating the class's members as private, which restricts access to or modification of them to the class's methods only. This is a crucial idea in object-oriented programming since it ensures the data's integrity and the class's proper operation. Syntax struct A struct is a composite data type used in the Go programming language that enables you to bring together related values of various types, such as a collection of fields or a collection of methods. Similar to ... Read More

Find Mean and Median of an unsorted Array in Java

Mr. Satyabrata
Updated on 31-Jan-2023 17:45:00
In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to find mean and median of an unsorted array in Java. Mean of an array can be derived by calculating the average value of all the elements present inside the array. Mean= (sum of all elements present in array) / (total number of elements present) Median of an array represents the middle element present in an odd number sorted array and if the sorted array consists of even number, then median can be ... Read More

How to Alter Two Array Elements in Java

Mr. Satyabrata
Updated on 31-Jan-2023 17:22:56
An array is a linear data structure in which elements are stored in contiguous memory locations. As per problem statement, we have to alter two array elements with each other. Altering two array elements in other words can also be called swapping or exchanging two elements with each other Let’s explore the article to see how it can be done by using Java programming language. To Show you Some Instances Instance-1 Suppose we have the below array = [10, 2, 3, -5, 99, 12, 0, -1] Now if we swap the 5th and 8th elements, Then, we have the new ... Read More

How Java is Helpful for Artificial Intelligence (AI)?

Mr. Satyabrata
Updated on 31-Jan-2023 17:14:53
Artificial Intelligence (AI) has been a hot topic for some time now & for good reason. AI has the potential to revolutionize many aspects of our everyday lives, from healthcare to education to transportation. The rise of artificial intelligence (AI), which has replaced all previous technologies, is being seen around the world. And one of the key technologies powering AI is Java. Exploring the Power of Java for AI Development Java is a popular programming language that was first released in 1995. It is known for its versatility & ease of use, which makes Java a great choice for AI ... Read More

Find Number of Array Elements Smaller than a Given Number in Java

Mr. Satyabrata
Updated on 31-Jan-2023 16:47:10
An array is a linear data structure in which elements are stored in contiguous memory locations. As per the problem statement, finding number elements smaller than a given number means we need to compare and count only the smaller elements in the array. Let’s explore the article to see how it can be done by using Java programming language. To show you some instances Instance-1 Suppose we have the below array [10, 2, 3, -5, 99, 12, 0, -1] and the number is 9 Now the number of elements that are smaller than 9 are [2, 3, -5, 0, -1] ... Read More

Find Elements Greater Than a Given Number In a Subarray in Java

Mr. Satyabrata
Updated on 31-Jan-2023 16:36:13
In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have given a sub array and a number and we have to find how many elements in this sub array are greater than that given number. So, we have to compare every element of the array with the given number and print the element if anyone is greater. Let’s explore the article to see how it can be done by using Java programming language. To Show you Some Instances Instance-1 Given Array= [12, 23, 34, ... Read More

Find All the Subarrays of a Given Array in Java

Mr. Satyabrata
Updated on 31-Jan-2023 16:31:25
An array is a linear data structure in which elements are stored in contiguous memory locations. As per problem statement, we have to find all the subarrays of a given array. Subarrays are part or a section of an array. When we talk about all subarrays of an array, we talk about the total number of combinations that can be made using all the elements of the array without repeating. Let’s explore the article to see how it can be done by using Java programming language. To Show you Some Instances Instance-1 Suppose we have the below array [10, ... Read More

Find Array Elements Which has at Least One Smaller Element in Java

Mr. Satyabrata
Updated on 31-Jan-2023 15:28:10
An array is a linear data structure in which elements are stored in contiguous memory locations. As per problem statement, we need to print all elements that have at least one smaller element. In simple terms we can say printing all elements of the array except the smallest one as the smallest one does not have any smaller element than this. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose we have the below array [10, 2, 3, -5, 99, 12, 0, -1] Now all elements ... Read More
Previous 1 ... 4 5 6 7 8 9 10 ... 3160 Next
Advertisements