Questions tagged [tostring]

"toString" or "ToString" is a major formatting method or function used in high level programming languages. It converts an Object to its string representation so that it is suitable for display.

toString() is a function which can be overridden.

toString

The toString() method is widely used to represent objects as human-readable text and practically every class should implement it. Usually it is very simple: generated string contains the object type and lists values of the most important fields. That's why process of writing such methods can easilly be automated. Eclipse, as the best java IDE in the world, should include functionality of automatic toString() method generation to make its users lives even simpler. Implementing it is the aim of this project.

Java represents this as the toString() method where C# represents it as ToString().

2528 questions
0
votes
2 answers

toString method Not Capitalizing Letters

I'm learning Java for a class and one of the assignments I need to do is implementing String methods into my code. After prompting the user to set text, I used a toLowerCase() method and printed it. On another line, I used a toUpperCase() method and…
Matt
  • 13
  • 3
0
votes
1 answer

Runtime of Arrays.toString()?

What is the run time (with regard to Big O) of the Arrays.toString() method in Java? e.g. String sort(String x){ char[] xArray = x.toCharArray(); Arrays.sort(xArray); return Arrays.toString(xArray);
Joanna
  • 13
  • 1
  • 6
0
votes
3 answers

How do I ignore the null values?

In my database I got 4 fields of data, I also got a method (getWalletName) where I send an SQL query to retrieve only one piece of data out of 4, but after retrieving and displaying the result. I can see the other data beside the desired one I want…
Yamen
  • 23
  • 5
0
votes
0 answers

the method toString(long) in the type Long is not applicable for the arguments (void)

I am getting compile time error while converting already set model class object into string in my project. In the AlmUserVO class ICA was set to long. **String temp = Long.toString(almUserVO.setIca(0));** tried with below alternate long l=…
0
votes
1 answer

Time2Test (with user input)

I am looking for some assistance with completing the assignment of Time2 with a test class involving user input. The assignment is: Modify the Time2 class (below) to implement the time as the number of seconds since midnight. The class should have…
Snowbrd1
  • 15
  • 5
0
votes
1 answer

Inheritance - Creating a class Commission Employee from class Employee and testing

Good Morning, I've been given the assignment to: rewrite the CommissionEmployee class as a subclass of Employee. CommissionEmployee should contain only the instance variables and methods that are not declared in superclass Employee.…
Snowbrd1
  • 15
  • 5
0
votes
1 answer

how to return filled array item in user defined class toString method?

the method should return all filled items from the array but instead, it returns the last item from the array. public String toString() { String result = ""; for( int i = 0; i < list.length; i++ ) { result = …
0
votes
5 answers

.ToString() and .ToLower() gives warning about culture differences

I am storing some boolean values as string session variables, like this: HttpContext.Session.SetString("SomeBool", user.SomeBool.ToString().ToLower()); This gives me warnings that the result could vary depending on the users culture. How is that…
Stian
  • 1,522
  • 2
  • 22
  • 52
0
votes
1 answer

How do I set the format of toString methods with ToStringBuilder in commons-lang?

how do I configure the setting of the format for toString
flybywire
  • 261,858
  • 191
  • 397
  • 503
0
votes
3 answers

How to use toString in this example?

Currently doing some homework and having trouble - I'm not sure how to use toString correctly. Here's the homework question: Create a class named Vehicle that acts as a superclass for vehicle types. The Vehicle class contains private variables for…
Avaka
  • 3
  • 3
0
votes
2 answers

Stack overflow from recursive toString function after swapping Linked List nodes

I am getting a stack overflow when I am using my recursive toString function on my Linked List after I am swapping the head node and another node in the middle of my Linked List. I am not sure as why this is happening and was hoping I can get some…
0
votes
2 answers

How are binary floating points (IEEE 754) converted to decimal (i.e. to string)?

It's possibly a very stupid question, but I've been searching for a whole day and I couldn't get an answer... Let's say I have a double-precision floating point literal: 5.21. Calling Double.toString( 5.21 ) in Java yields the string "5.21". Now,…
Samū
  • 488
  • 3
  • 15
0
votes
0 answers

android studio toString method is not found

i'm working on a project in android studio but when i want to use toString() method it shows : cannot resolve method 'toString()'.please check the image.enter image description here etLPassword = findViewById(R.id.etLPassword); String password =…